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 fileSolution:Jump to solution
in your project folder run
npm install serve
then change your start command to serve dist -s -n -L -p $PORT
...20 Replies
can you share your repo please
Sure one sec
GitHub
GitHub - scritto-xyz/scritto-fe
Contribute to scritto-xyz/scritto-fe development by creating an account on GitHub.
Solution
in your project folder run
npm install serve
then change your start command to serve dist -s -n -L -p $PORT
Let me give that a try
any reason you don't have a lock file in this repo?
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
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?
yarn
thanks for the info i'll get a lockfile pushed
then you'd want to have a yarn.lock file
changes deploying, will let you know how it goes
I have made a grave mistake
oh no
start command should actually be
serve dist -s -n -L -p $PORT
lol
sorry
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
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
thanks i'll def give that a read
no problem!