Enable Cors on Any Host #62
-
How do i enable cors from any host? I tried But neither worked. Invalid URI: The hostname could not be parsed. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Wouldn't this be the same as disabling CORs? If that is your objective, just don't include the CORs middleware. |
Beta Was this translation helpful? Give feedback.
-
sever.UseCorsPolicy(); This adds context.Response.AddHeader("Access-Control-Allow-Origin", "*");
context.Response.AddHeader("Access-Control-Allow-Headers", "X-Requested-With"); There are additional extensions that take parameters that allow you to configure the CORS policy to your liking, but this approach does the wild card CORS, which is what I think you're asking about. |
Beta Was this translation helpful? Give feedback.
This adds
OnRequest
middleware that does the following for all incoming requests:There are additional extensions that take parameters that allow you to configure the CORS policy to your liking, but this approach does the wild card CORS, which is what I think you're asking about.