C#

CORS in ASP.NET Core

Në shqip: CORS në ASP.NET Core

ShpjegimiSQ

Që një frontend në një domen tjetër (p.sh. React në localhost:5173) të thërrasë API-n tënde, duhet ta lejosh me AddCors() dhe UseCors() — përndryshe shfletuesi e bllokon.

EnglishEN

For a frontend on another domain (e.g. React on localhost:5173) to call your API, you allow it with AddCors() and UseCors() — otherwise the browser blocks it.

Si ta mendosh

Si lista e mysafirëve të lejuar në hyrje.

Lexoje në anglisht

Like the allowed-guests list at the entrance.

Shembull kodicsharp

builder.Services.AddCors(o => o.AddDefaultPolicy(p =>
    p.WithOrigins("http://localhost:5173").AllowAnyHeader().AllowAnyMethod()));
app.UseCors();

Terma të lidhur