Skip to content

Instantly share code, notes, and snippets.

@rfaisal
Created January 13, 2014 20:21
Show Gist options
  • Save rfaisal/8407346 to your computer and use it in GitHub Desktop.
Save rfaisal/8407346 to your computer and use it in GitHub Desktop.
public void ConfigureAuth(IAppBuilder app)
{
//other stuff
app.Use(async (context, next) =>
{
IOwinRequest req = context.Request;
IOwinResponse res = context.Response;
if (req.Path.StartsWithSegments(new PathString("/Token")))
{
var origin = req.Headers.Get("Origin");
if (!string.IsNullOrEmpty(origin))
{
res.Headers.Set("Access-Control-Allow-Origin", origin);
}
if (req.Method == "OPTIONS")
{
res.StatusCode = 200;
res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Methods", "GET", "POST");
res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Headers", "authorization", "content-type");
return;
}
}
await next();
});
//other stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment