Skip to content

Commit 17957ff

Browse files
committed
build: fix dev-server running in snippet mode (#18679)
Browsersync has 3 possible modes. `snippet`, `proxy` and `server`. We currently run with `snippet` even though we actually want to serve with the live-reloading script being injected automatically. In order to ensure that Browsersync runs in the `server` mode and properly prints the URL to the http server, we re-enable the `server` option that has been disabled in the past for security reasons. The logic to prevent directory traversal still remains, and we also explicitly disable directory listing (even though we have manual request interception).
1 parent a7bf1d5 commit 17957ff

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/dev-server/dev-server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ export class DevServer {
2727
port: this.port,
2828
notify: false,
2929
ghostMode: false,
30-
server: false,
31-
logSnippet: false,
32-
middleware: (req, res) => this._bazelMiddleware(req, res),
30+
server: {
31+
directory: false,
32+
middleware: [(req, res) => this._bazelMiddleware(req, res)],
33+
},
3334
};
3435

3536
constructor(
@@ -72,6 +73,7 @@ export class DevServer {
7273
if (!absoluteJoinedPath.startsWith(absoluteRootPath)) {
7374
res.statusCode = 500;
7475
res.end('Error: Detected directory traversal');
76+
return;
7577
}
7678
}
7779

0 commit comments

Comments
 (0)