So when I open a file that references a hosted ASP.NET Web API 2.0
project, I get the error:
Possible cross-origin (CORS) issue? The URL origin (https://secreturl.amazonaws.com) does not match the page (file://). Check the server returns the correct 'Access-Control-Allow-*' headers.
I only get answers for enabling cores for an HTTP request pipeline but not for (file://
). I open the file from an index.html
file, with path file:///C:/Users/PCName/desktop/index.html
I assume the CORS have to be enabled in the Startup.cs
file in the ASP.NET Core Web API 2.0
Most browser implementations by default do not support CORS headers for local files (specifically they set the value to null
which cannot then be used in an Access-Control-Allow
header.)
The easiest thing to do is start a small server. If you've got Python installed, this is as easy as running python3 -m http.server 8000
in the C:/Users/PCName/desktop
directory, and then you can browse to localhost:8000
(there are other 'instant servers' out there!).
That way you can use Access-Control-Allow-*
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With