How to allow redirects blocked by the CORS policy in ASP.NET Core 7?

558 views Asked by At

I am trying to figure out how to authenticate a SAFE Stack app using Azure AD. The problem is that the challenge request does a redirect to the Azure AD login page, which gets blocked by the cors policy. Right now, I am not even trying to do that, but simply trying to figure out how to get it to redirect to google. I get the following error.

Access to XMLHttpRequest at 'http://www.google.com/' (redirected from 'http://localhost:8080/api/ITodosApi/getTodos') from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

    builder.Services.AddCors() |> ignore
    let app = builder.Build()
    app.UseCors(fun opts ->
        opts.WithOrigins("http://localhost:8080").AllowCredentials().AllowAnyMethod().AllowAnyHeader() |> ignore
        ) |> ignore

Setting the cors policy like this here doesn't seem to be doing anything. What should I do?

0

There are 0 answers