@@ -41,9 +41,28 @@ module.exports = class SockJSServer extends BaseServer {
41
41
constructor ( server ) {
42
42
super ( server ) ;
43
43
44
+ const webSocketServerOptions =
45
+ /** @type {NonNullable<WebSocketServerConfiguration["options"]> } */
46
+ (
47
+ /** @type {WebSocketServerConfiguration } */
48
+ ( this . server . options . webSocketServer ) . options
49
+ ) ;
50
+
51
+ /**
52
+ * @param {NonNullable<WebSocketServerConfiguration["options"]> } options
53
+ * @returns {string }
54
+ */
55
+ const getSockjsUrl = ( options ) => {
56
+ if ( typeof options . sockjsUrl !== "undefined" ) {
57
+ return options . sockjsUrl ;
58
+ }
59
+
60
+ return "/__webpack_dev_server__/sockjs.bundle.js" ;
61
+ } ;
62
+
44
63
this . implementation = sockjs . createServer ( {
45
64
// Use provided up-to-date sockjs-client
46
- sockjs_url : "/__webpack_dev_server__/sockjs.bundle.js" ,
65
+ sockjs_url : getSockjsUrl ( webSocketServerOptions ) ,
47
66
// Default logger is very annoy. Limit useless logs.
48
67
/**
49
68
* @param {string } severity
@@ -73,15 +92,8 @@ module.exports = class SockJSServer extends BaseServer {
73
92
} ;
74
93
75
94
const options = {
76
- .../** @type {WebSocketServerConfiguration } */
77
- ( this . server . options . webSocketServer ) . options ,
78
- prefix : getPrefix (
79
- /** @type {NonNullable<WebSocketServerConfiguration["options"]> } */
80
- (
81
- /** @type {WebSocketServerConfiguration } */
82
- ( this . server . options . webSocketServer ) . options
83
- )
84
- ) ,
95
+ ...webSocketServerOptions ,
96
+ prefix : getPrefix ( webSocketServerOptions ) ,
85
97
} ;
86
98
87
99
this . implementation . installHandlers (
0 commit comments