【发布时间】:2023-04-07 02:45:01
【问题描述】:
你好吗?
这是我的代码:
const router = Router();
router.use(
`${routePrefix}/v1/associate-auth/`,
associateAuthRoutesV1(router)
);
router.use(
`${routePrefix}/v1/associate/`,
JWTVerify,
associateRoutesV1(router)
);
app.use('/', router);
这是我的路线内容示例:
router.post('/', async (_req, res) => {
res.send('OK');
});
问题是: 当我没有在其中一个路由文件中设置 root('/') 时,Express 在 root ('/') 中使用相同的方法查找下一个文件。
如果没有指定路由,如何配置返回 404?
【问题讨论】:
标签: javascript node.js api express express-router