❔ 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
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
I used "*" but it doesn't work
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/
Doesn't work
That's because you're missing information. I suppose your error has changed?
what do you mean?
Tell me what is wrong in my code
Do you have a different error?
No
Does your build app have
useCors()
defined?The error specifies you're loading a resource from a different origin
I think this error comes from front end
because with svg's link I can open image
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
It is published server
What if you add
.AllowAnyHeader().AllowAnyMethod()
to your cors configuration?it does not work
I have only one idea to change something in html code
AllowANyOrigin()
?
This is a problem with your server thoughSame 😄
Not the frontend
Does your published server also have this??
maybe but I cant fix it because it is for devops
Does the published server maybe use a different origin altogether because it's published?
Ya
Well, it should work if it knows the proper origin. I am not sure what would cause it to not work now.
I can use this image in my admin panel but it does not work on main web
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.