【发布时间】:2019-08-15 19:15:51
【问题描述】:
我的页面依赖于路由参数(例如:slug),就像http://example.com/blog/:slug。此路由路径在我的 next.config.js 文件中正确定义:
module.exports = withPlugins(plugins, {
exportPathMap: (defaultPathMap) => {
return {
'/': { page: '/home/home' },
'/blog/:slug': { page: '/careers/careers' }
}
}
});
这在开发模式下运行项目时可以正常工作,但是一旦我将项目导出为静态,路由就无法访问,并且我从下一个收到常规 404 错误。
有没有办法在不使用查询参数的情况下解决这个问题?
http://example.com/?slug=123
这个解决方案https://github.com/zeit/next.js/blob/canary/examples/with-static-export/next.config.js 也是不可接受的,因为帖子来自后端 CMS
【问题讨论】:
标签: javascript reactjs next.js