You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Blazor WASM app and a Web Api to get called by Blzor via HttpClient. Both programs run on the same machine (and also in production environment which should not be to exotic for a small business application!).
Calling the Web Api from the Blazor client result in a client CORS exception
Access to fetch at 'http://localhost:4040/' from origin 'https://localhost:5001' 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.
which is the expected behavior for this case.
In an former api project I developed in PHP, that had the same client behavior, I can bypass the CORS exception by simply setting the response header.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a Blazor WASM app and a Web Api to get called by Blzor via HttpClient. Both programs run on the same machine (and also in production environment which should not be to exotic for a small business application!).
Calling the Web Api from the Blazor client result in a client CORS exception
Access to fetch at 'http://localhost:4040/' from origin 'https://localhost:5001' 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.
which is the expected behavior for this case.
In an former api project I developed in PHP, that had the same client behavior, I can bypass the CORS exception by simply setting the response header.
Please read the whole question on the site:
https://stackoverflow.com/questions/64858434/net5-0-blazor-wasm-cors-client-exception?noredirect=1#comment114676627_64858434
where I also posted the code.
Unfortunately nobody could answer it.
Beta Was this translation helpful? Give feedback.
All reactions