【发布时间】:2021-04-06 10:34:53
【问题描述】:
我想在项目构建后更新重定向路由。所以,我们在 BE Api 上有一个重定向路由。
我想动态获取它并实现到 next.config.js,这就是我试图做的。
const getUrls = () =>
new Promise(resolve => {
setTimeout(() => resolve(fetch("https://api.mocki.io/v1/a0b7f0b0").then(function(response) {
return response.json();
}).then(function(data) {
return data.data;
}) ), 3000);
});
// ExampleResponse = {
// "data":[
// {
// "source":"/test",
// "permanent":true,
// "destination":"/internet-application"
// }
// ]
// }
module.exports = {
poweredByHeader: false,
async redirects() {
return getUrls();
},
}
有没有办法做到这一点。我只想从数据库更新重定向。如果数据库更新可以触发重定向而不停止项目
【问题讨论】:
标签: javascript reactjs build next.js config