✅ CORS issue when making GET request to server running asp application.
Hi,
I have this api: https://wsapi.tyrells.net/api/categories
And this webapp: https://wordsearch.tyrells.net/
This is the CORS code in the api:
This is the error in the webapp console:
The server receives the request when fetching from the webapp.
Making a GET request works fine when opening https://wsapi.tyrells.net/api/categories in browser.
Have I done something blatantly incorrect? I have no idea where I've gone wrong.
Thanks
44 Replies
The webapp is hosted using cloudflare pages. I'm not sure if it makes a difference.
If i run the webapp from localhost I get the same error, but I expect that to happen because I havent included http://localhost:5173/ in the cors string array
is it the slash at the end of the url in the CORs string array
so a few things
one, I've never seen the CORS policy being constructed in
UseCors
before. Usually, you set it with AddCors
then activate the middleware with UseCors
and yes, the trailing slash should not be there. Not sure if its the issue here, but its not standardI'll redeploy without the trailing slashes first. then look into addcors docs.
this is more what I'd expect
Removing the trailing slashes didn't work.
I was using
in development so I just thought it would be the same.
I just opened your webapp and it seems fine to me?
im not getting any cors errors
click on single player, it makes the first fetch there
I did.
the request worked.
![No description](https://cdn.answeroverflow.com/1261741473066389616/image.png)
you can see the CORS header right there
are you able to select categories ?
![No description](https://cdn.answeroverflow.com/1261741687529537599/image.png)
yep
![No description](https://cdn.answeroverflow.com/1261741793356021780/image.png)
![No description](https://cdn.answeroverflow.com/1261741970771021927/image.png)