Frontend code on full stack application not working properly

jhardoin
TRIAL

a year ago

Repo I am trying to launch https://github.com/jhardoin/bookstoremern

The backend works fine. The frontend is not. It says in deploy logs:

> frontend@0.0.0 start

> vite

VITE v5.3.3 ready in 264 ms

Local: http://localhost:5173/

Network: use --host to expose

I have updated the port to 5173, but the page still shows up blank. My react variable is correct, and it works fine locally. The one problem that I see is when I go to the details section of the deploy log, it has edit frontend/railway.json in github. When i click on that it brings me to github /frontend/frontend/railway.json which obviously doesn't exist. I set the root directory is set to /frontend. I have the backend directory as /backend and it works, but if i click the change on github it has the same backend/backend/railway.json, which doesn't exist but still works.

Backend deployment:

https://bookstoremern-production.up.railway.app/

https://bookstoremern-production.up.railway.app/books

Frontend:https://lavish-heart-production.up.railway.app/

Frontend railway.json located in /frontend/railway.json:

{ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "runtime": "V2", "numReplicas": 1, "startCommand": "npm start", "sleepApplication": false, "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 } }

1 Replies

a year ago

You are trying to run a development server, there's a few reasons why that's far from ideal, mainly increased resource usage that results in increased costs, along with general instabilities and incompatibilities.

Here is an example Vite React app that uses a production-ready web server to serve the website -

https://github.com/brody192/vite-react-template

All you need to do is to copy its nixpacks.toml and Caddyfile into your repository.


Frontend code on full stack application not working properly - Railway Help Station