404 on deployed Vite + SolidJs app

Hi I've been trying to debug this issue for a week with no luck. Context: I've got a Solid Js app built by Vite all deployed to my Railway account. Problem: When I try to route to any route that isn't the root "/", I get a 404 in the deployed version of the app. However when I try to use the same route locally I don't get the error and the content is displayed correctly. Can anyone help me out with this? What I've done to try to resolve: - Added a _redirects file to the root of my repository - Added a base tag to my index.html head with an href pointing to the root route "/" - Confirmed that I have the correct solid plugin in my vite config json file
Solution:
in your project folder run npm install serve then change your start command to serve dist -s -n -L -p $PORT...
Jump to solution
20 Replies
Brody
Brody17mo ago
can you share your repo please
llamaculture
llamacultureOP17mo ago
Sure one sec
llamaculture
llamacultureOP17mo ago
GitHub
GitHub - scritto-xyz/scritto-fe
Contribute to scritto-xyz/scritto-fe development by creating an account on GitHub.
Solution
Brody
Brody17mo ago
in your project folder run npm install serve then change your start command to serve dist -s -n -L -p $PORT
llamaculture
llamacultureOP17mo ago
Let me give that a try
Brody
Brody17mo ago
any reason you don't have a lock file in this repo?
llamaculture
llamacultureOP17mo ago
no good reason, no is that recommended? I am not a frontend pro by any means, and I thought build files shouldn't get committed and got built in whatever environment they were deployed to
Brody
Brody17mo ago
build files shouldn't get committed you are correct about that, but a lock file is not a build file, it's recommended to have a lock file do you use npm or pnpm?
llamaculture
llamacultureOP17mo ago
yarn thanks for the info i'll get a lockfile pushed
Brody
Brody17mo ago
then you'd want to have a yarn.lock file
llamaculture
llamacultureOP17mo ago
changes deploying, will let you know how it goes
Brody
Brody17mo ago
I have made a grave mistake
llamaculture
llamacultureOP17mo ago
oh no
Brody
Brody17mo ago
start command should actually be serve dist -s -n -L -p $PORT
llamaculture
llamacultureOP17mo ago
lol
Brody
Brody17mo ago
sorry
llamaculture
llamacultureOP17mo ago
no worries i'll try that now holy cow that worked thanks so much i've been losing hair over this if i get rich and famous some day i'll put you in my memoir
Brody
Brody17mo ago
lmao thank you I wrote this guide too, if you wanna learn more about that start command, it's for a create react app but very similar start command https://help.railway.app/project-help/f9v3gkPQRy4UShk5SnoPDH/getting-your-create-react-app-running-on-railway/qHRsgxa5n57xLp1yVgk9fP
llamaculture
llamacultureOP17mo ago
thanks i'll def give that a read
Brody
Brody17mo ago
no problem!
Want results from more Discord servers?
Add your server