【问题标题】:Service nextjs page inside ready working nodejs/exress app在准备好工作的 nodejs/express 应用程序中服务下一个 js 页面
【发布时间】:2022-01-06 06:31:21
【问题描述】:

我有一个使用 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

我该怎么做?

【问题讨论】:

    标签: node.js express next.js


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-19
      • 2019-03-07
      • 2017-03-02
      • 1970-01-01
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多