.Net 6 and No 'Access-Control-Allow-Origin' header is present on the requested resource

Hi there,

I’m working on a project where I implemented Auth0 authentication, and I’ve been able to do it correctly. This project is based on .Net 6 / WASM.

Login, Token Request, Call my C# API with that token. All go well.

My .Net API CORS config actually allow AnyOrigins, AnyHeader, …

But I went into an issue that I can’t find a solution for.

I Upload my SQL Database, C# API and Blazor App to Azure. The database and backend are working well, but I’m facing a issue when requesting the Token from the Blazor App when hosted on Azure.

Here the complete message

Access to fetch at 'https://dev-xxxxxxxx.us.auth0.com/oauth/token' from origin 'https://xxxxxxxx.azurewebsites.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

But when configure my Blazor App to connect to my azure host API work well, I mean the API return me the data request.

I only get Access-Control-Allow-Origin error when I try to run my app from Azure.

I’ve added the https://xxxxxxxx.azurewebsites.net’ the the Auth0 app config.

  • Allowed Web Origins

  • Allowed Origins (CORS)

Is there something that I miss?

Is there a bug in Auth0 related to .Net 6?

Thanks Hugo

Ok Git it … For the record

I saw what went wrong in the Auth0 monitoring/Logs It appear that I add the Origin at the wrong Auth0 Application config. Feeling dumm.

Hi @hugodufort,

I’m happy to hear that you resolved your issue! We’ve all been there.

Thank you for sharing the solution with the rest of the Community!

Have a great rest of your day.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.