Home > database >  Service nextjs page inside ready working nodejs/exress app
Service nextjs page inside ready working nodejs/exress app

Time:01-07

I have a nodejs application using express as a framework

example: localhost:2020

this app serves many routes

example: localhost:2020/node-1, localhost:2020/node-2localhost:2020/node-3

I created a nextjs application for just one page

example: localhost:3000/nextjs-page

I want to serve the new nextjs page inside my working node app to be localhost:2020/nextjs-page

how can i do that?

CodePudding user response:

Try express-http-proxy. Install it and include on app on localhost:2020, and then setup the middleware:

//localhost:2020 app
const proxy = require('express-http-proxy');

//...

app.use('/nextjs-page', proxy('http://localhost:3000/nextjs-page'));
  •  Tags:  
  • Related