❔ CORS error

Hello, I have Cors error on my project. I add Addpolicy in my configureServices and also add app.UseCors() in configure but I have same error. Does anyone know how to fix it and where do I have Problem? code below:
25 Replies
Monsieur Wholesome
Take a look at your network tab and see what origin header it uses in the failed request And copy that 1:1 to your policy
Saba Jangidze
Saba JangidzeOP2y ago
I used "*" but it doesn't work
FusedQyou
FusedQyou2y ago
Remove the trailing / Right now you set up the whole host rather than the origin. Pretty confusing, but https://localhost:44389 is your origin, rather than https://localhost:44389/
Saba Jangidze
Saba JangidzeOP2y ago
Doesn't work
FusedQyou
FusedQyou2y ago
That's because you're missing information. I suppose your error has changed?
Saba Jangidze
Saba JangidzeOP2y ago
what do you mean? Tell me what is wrong in my code
FusedQyou
FusedQyou2y ago
Do you have a different error?
Saba Jangidze
Saba JangidzeOP2y ago
No
FusedQyou
FusedQyou2y ago
Does your build app have useCors() defined?
Saba Jangidze
Saba JangidzeOP2y ago
FusedQyou
FusedQyou2y ago
The error specifies you're loading a resource from a different origin
Saba Jangidze
Saba JangidzeOP2y ago
I think this error comes from front end because with svg's link I can open image
FusedQyou
FusedQyou2y ago
I actually misread the error myself and didn't realise it was a whole different url in the first place Is the svg located on a website you own? Is it your published server? The error comes from the frontend because it's attempting to fetch something that it is not allowed to fetch, because that svg is located on a website that doesn't have CORS configured to allow it to be fetched
Saba Jangidze
Saba JangidzeOP2y ago
It is published server
FusedQyou
FusedQyou2y ago
What if you add .AllowAnyHeader().AllowAnyMethod() to your cors configuration?
Saba Jangidze
Saba JangidzeOP2y ago
it does not work I have only one idea to change something in html code
FusedQyou
FusedQyou2y ago
AllowANyOrigin()? This is a problem with your server though
Saba Jangidze
Saba JangidzeOP2y ago
Same 😄
FusedQyou
FusedQyou2y ago
Not the frontend Does your published server also have this??
Saba Jangidze
Saba JangidzeOP2y ago
maybe but I cant fix it because it is for devops
FusedQyou
FusedQyou2y ago
Does the published server maybe use a different origin altogether because it's published?
Saba Jangidze
Saba JangidzeOP2y ago
Ya
FusedQyou
FusedQyou2y ago
Well, it should work if it knows the proper origin. I am not sure what would cause it to not work now.
Saba Jangidze
Saba JangidzeOP2y ago
I can use this image in my admin panel but it does not work on main web
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server