Skip to content

Commit 0bd1632

Browse files
Update CorsHandler.cs
Testing the CorsHandler on FF and Chrome has issues due to missing authentication headers in the CorsResponse. As jQuery does not perform pre-flight checks a Cors request will never succeed using the mechanism described. I have added the most common headers to the response, but need to consider custom headers sent to the server. Reqards Gary
1 parent bb62c5a commit 0bd1632

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/DotNetOpenAuth.WebAPI/CorsHandler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
3737
} else {
3838
return base.SendAsync(request, cancellationToken).ContinueWith<HttpResponseMessage>(t => {
3939
HttpResponseMessage resp = t.Result;
40+
/*This fixes the problem with CorsRequests using credentials in FF and Chrome*/
41+
resp.Headers.Add("Access-Control-Allow-Credentials", "true");
42+
resp.Headers.Add(AccessControlAllowMethods, "GET, POST, PUT, DELETE");
43+
resp.Headers.Add(AccessControlAllowHeaders, "Authorization");
44+
4045
resp.Headers.Add(AccessControlAllowOrigin, request.Headers.GetValues(Origin).First());
4146
return resp;
4247
});
@@ -46,4 +51,4 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
4651
}
4752
}
4853
}
49-
}
54+
}

0 commit comments

Comments
 (0)