@epic-web/workshop-app 5.9.4 → 5.10.0
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/build/server/index.js +2 -0
- package/build/server/index.js.map +1 -1
- package/dist/server/index.js +11 -5
- package/package.json +3 -3
package/dist/server/index.js
CHANGED
|
@@ -110,6 +110,10 @@ const desiredPort = Number(process.env.PORT || 5639);
|
|
|
110
110
|
const portToUse = await getPort({
|
|
111
111
|
port: portNumbers(desiredPort, desiredPort + 100)
|
|
112
112
|
});
|
|
113
|
+
const localIp = ipAddress() ?? "Unknown";
|
|
114
|
+
const lanUrl = /^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(
|
|
115
|
+
localIp
|
|
116
|
+
) ? `http://${localIp}:${portToUse}` : null;
|
|
113
117
|
const server = app.listen(portToUse, async () => {
|
|
114
118
|
const addy = server.address();
|
|
115
119
|
const portUsed = desiredPort === portToUse ? desiredPort : addy && typeof addy === "object" ? addy.port : 0;
|
|
@@ -122,11 +126,6 @@ const server = app.listen(portToUse, async () => {
|
|
|
122
126
|
}
|
|
123
127
|
console.log(`\u{1F428} Let's get learning!`);
|
|
124
128
|
const localUrl = `http://localhost:${portUsed}`;
|
|
125
|
-
let lanUrl = null;
|
|
126
|
-
const localIp = ipAddress() ?? "Unknown";
|
|
127
|
-
if (/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(localIp)) {
|
|
128
|
-
lanUrl = `http://${localIp}:${portUsed}`;
|
|
129
|
-
}
|
|
130
129
|
console.log(
|
|
131
130
|
`
|
|
132
131
|
${chalk.bold("Local:")} ${chalk.cyan(localUrl)}
|
|
@@ -159,6 +158,13 @@ if (process.env.EPICSHOP_DEPLOYED !== "true" && process.env.EPICSHOP_ENABLE_WATC
|
|
|
159
158
|
server.on("upgrade", (request, socket, head) => {
|
|
160
159
|
const url = new URL(request.url ?? "/", "ws://localhost:0000");
|
|
161
160
|
if (url.pathname === "/__ws") {
|
|
161
|
+
const origin = request.headers.origin;
|
|
162
|
+
const isValidOrigin = origin && (origin === `http://localhost:${portToUse}` || origin === `http://127.0.0.1:${portToUse}` || lanUrl && origin === lanUrl);
|
|
163
|
+
if (!isValidOrigin) {
|
|
164
|
+
socket.write("HTTP/1.1 403 Forbidden\r\n\r\n");
|
|
165
|
+
socket.destroy();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
162
168
|
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
163
169
|
const watchPaths = url.searchParams.getAll("watch");
|
|
164
170
|
if (watchPaths.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epic-web/workshop-app",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@epic-web/invariant": "^1.0.0",
|
|
45
45
|
"@epic-web/remember": "^1.1.0",
|
|
46
46
|
"@epic-web/restore-scroll": "^1.1.1",
|
|
47
|
-
"@epic-web/workshop-presence": "5.
|
|
48
|
-
"@epic-web/workshop-utils": "5.
|
|
47
|
+
"@epic-web/workshop-presence": "5.10.0",
|
|
48
|
+
"@epic-web/workshop-utils": "5.10.0",
|
|
49
49
|
"@mdx-js/mdx": "^3.0.1",
|
|
50
50
|
"@mux/mux-player-react": "^3.0.0",
|
|
51
51
|
"@nasa-gcn/remix-seo": "^2.0.1",
|