I am trying to submit a form in Angular, through JSS. In chrome, I get a CORS error complaining the access-control-allow-origin header is missing. Just for fun, I added this to application_beginRequest in global.asax.cs:
if (HttpContext.Current.Request.HttpMethod == "OPTIONS" && HttpContext.Current.Request.Path.StartsWith("/api/jss/formbuilder"))
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true");
HttpContext.Current.Response.StatusCode = 200;
HttpContext.Current.Response.End();
}
But I still get CORS errors, the code isn't even hit. When I attach the debugger, I actually catch this exception in Application_Error():
"The required anti-forgery cookie \"__RequestVerificationToken\" is not present."
, hinting that it's not even a CORS issue, as Chrome suggests.
In the browser, I can see the token being included with the form data: __RequestVerificationToken: {random string}
. I know it isn't being cached, since I can refresh and see a new token passed.
This all happens in Chrome & Brave, but not Firefox. What is going on??