Skip to content

Commit 2adc376

Browse files
committed
Refactor to handle base path configuration
1 parent 397c4b6 commit 2adc376

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

server.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import(`${configPath}/config.mjs`).then((module) => {
88
const config = module.default;
99

1010
app.use(
11-
config.base,
12-
express.static(path.join(fileURLToPath(configPath), "dist")),
11+
config.base || "/",
12+
express.static(path.join(fileURLToPath(configPath), "dist"))
1313
);
1414

1515
app.get("*", (req, res) => {
@@ -18,10 +18,11 @@ import(`${configPath}/config.mjs`).then((module) => {
1818

1919
const port = process.env.PORT || config.port || 3000;
2020

21+
let message = `Server running on port ${port}`;
22+
config.base && (message += ` with base ${config.base}`);
23+
2124
app.listen(port, () => {
22-
console.log(
23-
`\x1b[36m%s\x1b[0m`,
24-
`Server running on port ${port} with base ${config.base}`,
25-
);
25+
console.log(`\x1b[36m%s\x1b[0m`, message);
2626
});
2727
});
28+

0 commit comments

Comments
 (0)