Fix CORS on TS Client (#1652)

This commit is contained in:
BrennanConroy 2018-03-19 22:01:28 -07:00 committed by GitHub
parent 4f10560087
commit 473e578efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View File

@ -54,6 +54,7 @@ export class DefaultHttpClient extends HttpClient {
const xhr = new XMLHttpRequest();
xhr.open(request.method, request.url, true);
xhr.withCredentials = true;
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
if (request.headers) {

View File

@ -145,7 +145,7 @@ export class ServerSentEventsTransport implements ITransport {
url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`;
}
const eventSource = new EventSource(url);
const eventSource = new EventSource(url, { withCredentials: true });
try {
eventSource.onmessage = (e: MessageEvent) => {

View File

@ -38,7 +38,8 @@ namespace SocketsSample
{
p.AllowAnyHeader()
.AllowAnyMethod()
.AllowAnyOrigin();
.AllowAnyOrigin()
.AllowCredentials();
});
});