a year ago
Hello! I am able to build and preview my project locally, however it does not contain a start command so it's failing to build on railway.
I saw workarounds that mentioned adding a nixpacks.toml file and using Caddy, yet surely there must be a simpler way to get the index.html served up? I'm not sure what to add for the custom start command and it's not really clear to me from the docs. Any advice would be appreciated, thank you!
ⓘ Deployment information is only viewable by project members and Railway employees.
10 Replies
a year ago
For frontend SPAs Railway does not run a web server for you like vercel would, so the nixpacks.toml and Caddyfile starts a web server and serves your built site.
a year ago
For frontend SPAs Railway does not run a web server for you like vercel would, so the nixpacks.toml and Caddyfile starts a web server and serves your built site.
Hello, thank you for the quick response! I saw earlier this example repo you made, however I don't see a start command in the package.json. So if I add the other files like you have here, will it still start ok, or will I have to add a custom command please? Thank you!
https://github.com/brody192/vite-react-template/blob/main/package.json
Edit: ok I see from looking further that in the nixpacks file it gives some instructions mentioning Caddy so that must be controlling the build process. I'll try to add these to my project and see if it works
a year ago
Ok I tried copying exactly what you had in those two files and at least it started building but it timed out. I think I'll use another service that's more compatible with Vite for this project, however I wanted to try to use Railway for the future. Can you please let me know if you have any advice regarding why it timed out in this case? Here's the repo link although I'm going to remove the Caddy stuff now. Thanks!
a year ago
I don't see a start command in the package.json
The start command that starts caddy in located in the nixpacks.toml file.
So if I add the other files like you have here, will it still start ok, or will I have to add a custom command
Yep it will start caddy by default, in fact you would want to remove any start commands you may have set elsewhere like a Procfile, railway.json, or in your service settings.
looking into your repo now, once you have this setup correctly is set and forget!
Edit: two issues found -
You are committing your dist
folder, you would want to remove that from GitHub and than make sure it's in your .gitignore
You have the --watch
flag on vite build
in the build script of your package.json, this is causing the build to never exit and thus your build on Railway hangs and eventually times out, something like vercel may automatically fix that for you, but on Railway your code and config is ran as-is.
P.S. hope you haven't left the platform while I was asleep haha
a year ago
Thanks! I appreciate the help! I actually did however I had issues deploying on the other service provider as well, and I've come back here afterwards haha. It looks like it deployed successfully now! I have an existing domain with GoDaddy yet it looks like there are issues using an @ level CNAME that isn't letting me update the DNS records properly. Should I create a separate question to ask for help with that issue please? Thanks!
a year ago
This thread is fine for any questions that relates to the same service.
You don't need to transfer the domain, but you would need to use Cloudflare's nameservers as they do support root level CNAMEs.
a year ago
Thank you! Do you have any other recommended nameservers? I would rather not use Cloudflare for anything.
a year ago
Namecheap also supports root level cnames, but I'm not sure if you can just use their nameservers without transferring the domain.
Another option would be DNSimple and their ALIAS record type -
https://support.dnsimple.com/articles/alias-record/
Please note that while other providers may offer an ALIAS type, they likely won't do the dynamic lookup for every request behind the scenes that DNSimple does, this is needed because the IPs Railway uses may change at any time.
And if you're okay with sharing, may I ask why you'd rather not use Cloudflare?
a year ago
Thank you for the help! I'm not personally a fan of their policies overall, so I'd rather use a different service if possible. If that means transferring the domains I may need to look into that as well. I'll check out Namecheap and DNSimple!