Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions lib/servers/SockJSServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,28 @@ module.exports = class SockJSServer extends BaseServer {
constructor(server) {
super(server);

const webSocketServerOptions =
/** @type {NonNullable<WebSocketServerConfiguration["options"]>} */
(
/** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options
);

/**
* @param {NonNullable<WebSocketServerConfiguration["options"]>} options
* @returns {string}
*/
const getSockjsUrl = (options) => {
if (typeof options.sockjsUrl !== "undefined") {
return options.sockjsUrl;
}

return "/__webpack_dev_server__/sockjs.bundle.js";
};

this.implementation = sockjs.createServer({
// Use provided up-to-date sockjs-client
sockjs_url: "/__webpack_dev_server__/sockjs.bundle.js",
sockjs_url: getSockjsUrl(webSocketServerOptions),
// Default logger is very annoy. Limit useless logs.
/**
* @param {string} severity
Expand Down Expand Up @@ -73,15 +92,8 @@ module.exports = class SockJSServer extends BaseServer {
};

const options = {
.../** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options,
prefix: getPrefix(
/** @type {NonNullable<WebSocketServerConfiguration["options"]>} */
(
/** @type {WebSocketServerConfiguration} */
(this.server.options.webSocketServer).options
)
),
...webSocketServerOptions,
prefix: getPrefix(webSocketServerOptions),
};

this.implementation.installHandlers(
Expand Down