How do I fixt the Okta/React/.NET CORS Preflight Error?

167 Views Asked by At

I'm trying to use Okta for user authentication.

The stack is ASP.net core and react. This is the new template where react and the ASP.net core API projects are separate.

I have the Okta example working, but the .net react project doesn't. I can't figure out the difference between the two.

I'm getting this error: Access to fetch at '...' from origin 'https://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response servers your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I have localhost:3000 as a Trusted Origin.

enter image description here

I have localhost:3000/login/callback as the sign in URIs: enter image description here

This is the older version of Okta developer.

Can someone please help me figure out how to get this to work?

I've tried copying the example directly into Visual Studio. I've tried running from cmd instead of VS. I've tried changing the ports and paths. I've tried https/http.

For everything I've tried, I still get the CORS error.

0

There are 0 best solutions below