feat(build): bundle frontend with vite and matrix-js-sdk, fix HOST in server.js
This commit is contained in:
1 parent
5ce3b46bab
commit
b6cc9f3465
8 files changed
+3421
-9
No files matched your search
@@ -10,7 +10,9 @@ const { WebSocketServer } = require('ws');
|
||||
|
||||
const PORT = Number(process.env.PORT || 8080);
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
const PUBLIC_DIR = path.join(__dirname, 'public');
|
||||
const STATIC_DIR = fs.existsSync(path.join(__dirname, 'dist'))
|
||||
? path.join(__dirname, 'dist')
|
||||
: path.join(__dirname, 'public');
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ICE configuration: env-driven, full JSON override wins.
|
||||
@@ -74,8 +76,8 @@ const MIME = {
|
||||
function serveStatic(req, res) {
|
||||
const urlPath = decodeURIComponent(new URL(req.url, 'http://x').pathname);
|
||||
let rel = urlPath === '/' ? '/index.html' : urlPath;
|
||||
const file = path.normalize(path.join(PUBLIC_DIR, rel));
|
||||
if (!file.startsWith(PUBLIC_DIR)) {
|
||||
const file = path.normalize(path.join(STATIC_DIR, rel));
|
||||
if (!file.startsWith(STATIC_DIR)) {
|
||||
res.writeHead(403).end('forbidden');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user