'Can we have Springboot jar + NextJs running on same port as a packaged Jar

Ideally NextJs code runs on a different port 3000. Can we have NextJS code clubbed in Springboot executable Jar /WAR (embedded Tomcat) which runs on default port 8080, and make the clubbed application jar/war run on single port?

Just want to highlight, React JS can be clubbed with Springboot , whereas NextJS I am no sure.



Solution 1:[1]

Next.js is written in Javascript, Spring Boot is written in Java, they cannot be run together. However, after you run them in different ports, you can use a reverse proxy (e.g. Nginx) to stick them together under the same port but different endpoints (for example map Next.js to / and Spring Boot to /api)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ian Lau