[Vuejs]-Ongoing CORS issues (Vue 3 / Axios + ASP.NET Core Web API (backend))

0👍

For testing at local, you should allow any domain access resource.
Replace this code with the one below

builder.Services.AddCors(options => 
{
    options.AddPolicy("AllowOrigin", policy => 
       {
           policy.AllowAnyOrigin()
                 .AllowAnyMethod()
                 .AllowAnyHeader()
                 .WithOrigins("http://localhost:5173");
       });    
});
builder.Services.AddCors(options => 
{
    options.AddPolicy("AllowOrigin", policy => 
       {
           policy.AllowAnyOrigin()
                 .AllowAnyMethod()
                 .AllowAnyHeader()
                 .WithOrigins("*");
       });    
});

Leave a comment