Created
January 13, 2014 20:21
-
-
Save rfaisal/8407346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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