This project has moved. For the latest updates, please go here.

StaticFiles and CORS

Feb 11, 2015 at 7:38 PM
I have a site that I need to enable client sites to request html or javascript files from but they are not getting the Access-Control-Allow-Origin header set. I've tried any number of configurations with Static files but to no avail. I've even tried to set it manually using
OnPrepareResponse = context =>
            {
                context.OwinContext.Response.Headers.Set("Access-Control-Allow-Origin",
                    context.OwinContext.Request.Headers.Get("Origin"));
            }
but the OnPrepareResponse never gets hit. It seems I should be able to support CORS on static file requests or am I wrong.
Coordinator
Feb 11, 2015 at 9:00 PM
Feb 12, 2015 at 1:31 AM
Edited Feb 12, 2015 at 1:32 AM
by setting RAMMFAR
<modules runAllManagedModulesForAllRequests="true" />
and then using my code
    OnPrepareResponse = context =>
            {
                context.OwinContext.Response.Headers.Set("Access-Control-Allow-Origin",
                    context.OwinContext.Request.Headers.Get("Origin"));
            }
But it seems like it would be cleaner to plug in to the existing CORS architecture.