Merge pull request #2552 from erasche/gie-proxy-issue

More defensive GIE Proxying
This commit is contained in:
Björn Grüning
2016-06-26 18:28:28 +02:00
committed by GitHub
+11 -3
View File
@@ -95,10 +95,15 @@ DynamicProxy.prototype.handleProxyRequest = function(req, res) {
this.rewriteRequest(req);
res.oldWriteHead = res.writeHead;
res.writeHead = function(statusCode, headers) {
try {
res.setHeader('Access-Control-Allow-Origin', origin);
if(origin){
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.setHeader('Access-Control-Allow-Credentials', 'true');
if(!headers){
headers = {};
}
res.oldWriteHead(statusCode, headers);
}
catch (error) {
@@ -128,8 +133,11 @@ DynamicProxy.prototype.handleWs = function(req, res, head) {
res.oldWriteHead = res.writeHead;
res.writeHead = function(statusCode, headers) {
try {
res.setHeader('Access-Control-Allow-Origin', origin);
if(origin){
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.setHeader('Access-Control-Allow-Credentials', 'true');
if(!headers){ headers = {}; }
res.oldWriteHead(statusCode, headers);
}
catch (error) {