CORS works well, but I don't like * in the Origin. I try do do the same in Application_BeginRequest:
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
//These headers are handling the "pre-flight" OPTIONS call sent by the browser
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "http://localhost:3312");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Accepts, Content-Type, Origin, X-My-Header");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "60");
HttpContext.Current.Response.End();
}
My idea was to put request host in the Origin as I'm allowed to have only 1 Origin domain.
When I check headers in the browser they looks the same but I have CORS error "
The Same Origin Policy disallows reading the remote resource..."
What to do to get it working?