Skip to content

Commit

Permalink
Add URL redirection in root route handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlee-06 committed Feb 6, 2025
1 parent a8f1534 commit 18f785b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ app.use(express.static(path.join(__dirname)));


app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '/public/'));
const requestedUrl = req.query.u;
if (!requestedUrl) {
res.sendFile(path.join(__dirname, '/public/'));
}
else {
res.redirect(requestedUrl);
}

});

// 接受 POST 請求的伺服器
Expand Down

0 comments on commit 18f785b

Please sign in to comment.