Browse Source

add routes with parameters to frontend server routing

pull/200/head
Dash8 2 months ago
parent
commit
962e37bdd3
  1. 4
      server/src/index.ts

4
server/src/index.ts

@ -36,7 +36,7 @@ app.get('/post/:pid', (req, res) => {
});
// handle communities
app.get(['/c/:cname', '/community/:cname'], (req, res) => {
app.get(['/c/:cname', '/community/:cname', '/c/:cname/data_type/*/sort/*/page/*', '/community/:cname/data_type/*/sort/*/page/*'], (req, res) => {
handleCommunity(`${req.protocol}://${req.get('Host')}${req.url}`, req.params.cname)
.then((html) => res.send(html))
.catch((e) => res.status(500).send(e));
@ -50,7 +50,7 @@ app.get('/post/:pid/comment/:cid', (req, res) => {
});
// handle users
app.get(['/u/:uname', '/user/:uname'], (req, res) => {
app.get(['/u/:uname', '/user/:uname', '/u/:uname/view/*/sort/*/page/*', '/user/:uname/view/*/sort/*/page/*'], (req, res) => {
handleUser(`${req.protocol}://${req.get('Host')}${req.url}`, req.params.uname)
.then((html) => res.send(html))
.catch((e) => res.status(500).send(e));

Loading…
Cancel
Save