在准备就绪的nodejs/express应用程序中服务nextjs页面



我有一个使用express作为框架的nodejs应用程序

示例:localhost:2020

该应用程序服务于许多路线

示例:localhost:2020/node-1, localhost:2020/node-2localhost:2020/node-3

我只为一页创建了一个nextjs应用程序

示例:localhost:3000/nextjs-page

我想在我的工作节点应用程序中提供新的nextjs页面为localhost:2020/nextjs-page

我该怎么做?

尝试express http代理。安装并包含在localhost:2020上的应用程序中,然后设置中间件:

//localhost:2020 app
const proxy = require('express-http-proxy');
//...
app.use('/nextjs-page', proxy('http://localhost:3000/nextjs-page'));

最新更新