6 months ago
Recently I wanted to optimize my React app which I was serving with Node for over a year. As the app was getting bigger, my usage was also expanding so I finally started to look into how to optimize it. I read that I can switch the node language with staticfile so that my deployement doesn't need to run on node. As that was generating a lot of cost.
But it seems my react app can't be served this way.
Things I tried:
npm run build, to build my app then deploy
adding _redrect file that points to my url
adding static.json file
I was wondering if I am missing anything in my project. I followed the best practices for this but I still find that my serving doesn't work. I attached snippet from sources console where my index file is not pointing to static route where I have all my assets:
Any tips or reccomedetions for this is much appreciated!
Attachments
4 Replies
6 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
Railway
Hey there! We've found the following might help you get unblocked faster: - [🧵 Vite React app Deployment Failed](https://station.railway.com/questions/vite-react-app-deployment-app-18276bae) - [🧵 Issues regarding deploying a React app](https://station.railway.com/questions/issues-regarding-deploying-a-react-app-5cd79a8a) - [📚 Deploy a React App](https://docs.railway.com/guides/react) If you find the answer from one of these, please let us know by solving the thread!
6 months ago
Doesn't really help my case unfortunetly
6 months ago
Hey, it is best to checkout the React + Vite template (source code), as it serves a static React app with Caddy, which is what you want to achieve. Additionally, there is a dedicated static sites section in the Railpack docs, which will give you more insight on how to set it up.
6 months ago
THe hting is I spend 2 years on and off building my project in React so now migrating to Vite would be a challange. I would like to see if I can do it with CRA instead as it is.