I am trying to build a ReactJS application which i would like to host on a tomcat server. I already used the command npm run build and the build is ready.. Where do i copy these files in my tomcat server? DO i need to create another application and deploy it on the server which invokes the React Application?
Asked
Active
Viewed 8,797 times
5
-
1This post might be helpful, https://stackoverflow.com/questions/40030580/how-to-run-a-react-app-on-tomcat – KungWaz Jan 21 '19 at 06:57
-
1Also, this post https://medium.com/@mukundmadhav/build-and-deploy-react-app-with-spring-boot-and-mysql-6f888eb0c600#d8c5 – Victor Jul 23 '20 at 11:36
1 Answers
1
Follow below steps:
- Goto 'webapp' folder in tomcat and create a folder(mostly your project name)
- Copy the files from your ReactJs build folder to the folder created in tomcat(note: your build folder should have index.html)
- Launch the url http : //localhost:< port > /< folder-name> in browser. By default port will be 8080
Instead if you have WAR file, you can go to http://localhost: < port > /manager/html and deploy it.

Rakesh Makluri
- 647
- 4
- 10
-
1I was facing similar requirements. I copied the build folder into webapps. In webapps now I have a folder named build and the contents of build folder inside that. But still I am unable to launch my application via tomcat – Geo Thomas May 27 '20 at 13:54
-
2
-
2I applied this steps but when i launch url i am getting 404 not found error – mertaksu Jul 13 '20 at 18:58
-
I am trying this solution and my react app searching for files in static folder in tomcat's root folder. when I add homepage in package.json file get searching get routed to folder. but still app is not working – Ashiq Apr 20 '21 at 06:45
-
@mertaksu for 404 this helps: https://stackoverflow.com/questions/41246261/react-routing-is-able-to-handle-different-url-path-but-tomcat-returns-404-not-av/41249464#41249464 – mostafa.S Oct 09 '21 at 11:44