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?
1 Answer
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.
5 Comments
Geo Thomas
I 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
Rakesh Makluri
did you try this http : //localhost:< port >/build ?
mertaksu
I applied this steps but when i launch url i am getting 404 not found error
Ashiq
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
mostafa.S
@mertaksu for 404 this helps: stackoverflow.com/questions/41246261/…