我使用 restinio 作为我的后端 API 服务器。以前我使用 ReactJS 作为前端,并使用 package.json 中的 "proxy": "http://localhost:4000" 解决了这个代理问题,如此处所述;https://create-react-app.dev/docs/proxying-api-requests-in-development/。
现在我正在使用 Next.js,我可以直接使用 fetch 函数从后端获取数据,但如果可能的话,我想使用 next-connect,因为这个模块有许多功能可以简化我当前项目的编码。
我尝试了几种方法,例如使用 rewrites 模块重写路径;
module.exports = {
async rewrites() {
return [
{
source: '/about',
destination: '/',
},
]
},
}
但仍然无法解决问题。我应该怎么做?
谢谢你。