@soundworks/core 4.0.0-alpha.23 → 4.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/client/Socket.js +23 -4
- package/src/common/version.js +1 -1
- package/src/server/Server.js +8 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## v4.0.0-alpha.25 - 24/05/2025
|
|
2
|
+
|
|
3
|
+
- Fix: better default behavior for websocket connection URL
|
|
4
|
+
|
|
5
|
+
## v4.0.0-alpha.24 - 24/05/2025
|
|
6
|
+
|
|
7
|
+
- Fix: unexpected behavior with new `serverAddress` behavior on browser clients and self-signed certificates
|
|
8
|
+
|
|
1
9
|
## v4.0.0-alpha.23 - 24/05/2025
|
|
2
10
|
|
|
3
11
|
- Breaking: remove binary socket
|
package/package.json
CHANGED
package/src/client/Socket.js
CHANGED
|
@@ -61,16 +61,34 @@ class Socket {
|
|
|
61
61
|
let webSocketOptions;
|
|
62
62
|
|
|
63
63
|
if (isBrowser()) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const hostname = window.location.hostname;
|
|
65
|
+
|
|
66
|
+
if (config.env.serverAddress === '') {
|
|
67
|
+
serverAddress = hostname;
|
|
67
68
|
} else {
|
|
69
|
+
serverAddress = config.env.serverAddress;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// when in https with self-signed certificates, we don't want to use
|
|
73
|
+
// the serverAddress defined in config as the socket would be blocked, so we
|
|
74
|
+
// just override serverAddress with hostname in this case
|
|
75
|
+
const localhosts = ['127.0.0.1', 'localhost'];
|
|
76
|
+
|
|
77
|
+
if (config.env.useHttps && localhosts.includes(hostname)) {
|
|
68
78
|
serverAddress = window.location.hostname;
|
|
69
79
|
}
|
|
70
80
|
|
|
81
|
+
if (config.env.useHttps && window.location.hostname !== serverAddress) {
|
|
82
|
+
console.warn(`The WebSocket will try to connect at ${serverAddress} while the page is accessed from ${hostname}. This can lead to socket errors, e.g. If you run the application with self-signed certificates as the certificate may not have been accepted for ${serverAddress}. In such case you should rather access the page from ${serverAddress}.`);
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
webSocketOptions = [];
|
|
72
86
|
} else {
|
|
73
|
-
|
|
87
|
+
if (config.env.serverAddress === '') {
|
|
88
|
+
serverAddress = '127.0.0.1';
|
|
89
|
+
} else {
|
|
90
|
+
serverAddress = config.env.serverAddress;
|
|
91
|
+
}
|
|
74
92
|
|
|
75
93
|
webSocketOptions = {
|
|
76
94
|
rejectUnauthorized: false,
|
|
@@ -155,6 +173,7 @@ class Socket {
|
|
|
155
173
|
// we want to log the warning just once
|
|
156
174
|
if (!connectionRefusedLogged) {
|
|
157
175
|
logger.log('[soundworks.Socket] Connection refused, waiting for the server to start');
|
|
176
|
+
// console.log(e.error);
|
|
158
177
|
connectionRefusedLogged = true;
|
|
159
178
|
}
|
|
160
179
|
|
package/src/common/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// [WARNING] This file is generated, do not edit
|
|
2
|
-
export default '4.0.0-alpha.
|
|
2
|
+
export default '4.0.0-alpha.25';
|
package/src/server/Server.js
CHANGED
|
@@ -75,7 +75,7 @@ const DEFAULT_CONFIG = {
|
|
|
75
75
|
env: {
|
|
76
76
|
type: 'development',
|
|
77
77
|
port: 8000,
|
|
78
|
-
serverAddress:
|
|
78
|
+
serverAddress: '',
|
|
79
79
|
subpath: '',
|
|
80
80
|
websockets: {
|
|
81
81
|
path: 'socket',
|
|
@@ -163,7 +163,7 @@ class Server {
|
|
|
163
163
|
* env: {
|
|
164
164
|
* type: 'development',
|
|
165
165
|
* port: 8000,
|
|
166
|
-
* serverAddress:
|
|
166
|
+
* serverAddress: '',
|
|
167
167
|
* subpath: '',
|
|
168
168
|
* websockets: {
|
|
169
169
|
* path: 'socket',
|
|
@@ -187,16 +187,12 @@ class Server {
|
|
|
187
187
|
throw new Error(`[soundworks:Server] Invalid "app.clients" config, at least one client should be declared`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (hasNodeClient && this.config.env.serverAddress === null) {
|
|
199
|
-
throw new Error(`[soundworks:Server] Invalid "env.serverAddress" config, is mandatory when a node client target is defined`);
|
|
190
|
+
// @peeka - remove
|
|
191
|
+
// [2024-05-29] Override default `config.env.serverAddress`` provided from
|
|
192
|
+
// template `loadConfig` to '' so that browser clients can default to
|
|
193
|
+
// window.location.hostname and node clients to `127.0.0.1`
|
|
194
|
+
if (process.env.ENV === undefined && this.config.env.serverAddress === '127.0.0.1') {
|
|
195
|
+
this.config.env.serverAddress = '';
|
|
200
196
|
}
|
|
201
197
|
|
|
202
198
|
if (this.config.env.useHttps && this.config.env.httpsInfos !== null) {
|