I have a Blazor WASM project that contains two projects:
I was originally able to run the solution locally just fine, but recently had to (re)clone the solution locally and now getting the following CORS errors when it trying to fetch the local API endpoints:
I confirmed the API endpoints load fine locally when loading directly:
Originally I had to add the following setting to 'appsettings.Development.json':
With the following in 'Program.cs':
This always allowed me to run locally and in production without any issues. I've confirmed the ports are correct.
Any thoughts on why I would be getting CORS errors now locally? I am little confused why it was working and then stopped after cloning repo...
If it helps you can look at the source code here:
Adding 'local.settings.json' file configured with the following CORS setting to my Azure Function API project resolved the issue for me:
{
"Values": {
},
"Host": {
"CORS": "*"
}
}
The following SO answer helped me (https://stackoverflow.com/a/60109518/443971).