Skip to content

Commit

Permalink
fix: add workaround for Origin header in sockjs (#1608)
Browse files Browse the repository at this point in the history
  • Loading branch information
3846masa authored and evilebottnawi committed Dec 24, 2018
1 parent bddfe16 commit 1dfd4fb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ const createCertificate = require('./utils/createCertificate');
const validateOptions = require('schema-utils');
const schema = require('./options.json');

// Workaround for sockjs@~0.3.19
// sockjs will remove Origin header, however Origin header is required for checking host.
// See https://github.com/webpack/webpack-dev-server/issues/1604 for more information
{
// eslint-disable-next-line global-require
const SockjsSession = require('sockjs/lib/transport').Session;
const decorateConnection = SockjsSession.prototype.decorateConnection;
SockjsSession.prototype.decorateConnection = function(req) {
decorateConnection.call(this, req);
const connection = this.connection;
if (connection.headers && !('origin' in connection.headers) && 'origin' in req.headers) {
connection.headers.origin = req.headers.origin;
}
};
}

// Workaround for node ^8.6.0, ^9.0.0
// DEFAULT_ECDH_CURVE is default to prime256v1 in these version
// breaking connection when certificate is not signed with prime256v1
Expand Down

0 comments on commit 1dfd4fb

Please sign in to comment.