In my Astro site one of the routes is routing to localhost
Hello.
I am trying to move my Astro site from Vercel, where it is currently working without problems (except for some bug in the Vercel integration that makes impossible to build static pages) to railway.
I created a docker image and managed to make it build properly. The site is deployed and available, but for some weird reason one of the routes that points to a static path is redirecting me to localhost. When I click the link first I see a white screen saying that I will be redirected to localhost, and them I am redirected to localhost.
Any idea why? Is this something Railway load balancer does?
42 Replies
Project ID:
c2147d2a-2ed6-4234-b48a-50d16f81e68c
c2147d2a-2ed6-4234-b48a-50d16f81e68c
Hey! Mind sharing a link? It doesn't look like something that neither Astro or Railway usually do
Check the first link https://boda-ali-dani-production.up.railway.app/
Boda de Ali y Dani
Boda de Alicia y danielo
By the way, I fixed the redirect by providing the public url of the site to Astro, so at least it now redirects to the right place
When testing this inside docker in my local machine accessing that url makes the server crash, which is why I assume the redirect happens
vercel will automatically intercept redirects to localhost and change them to redirect to the public address, railway will not do anything of the sort, when running on railway your code must send the correct redirect response
The app does not crash on Vercel, and no redirect happens, the right route is displayed
On railway there are no logs when I hit that route wich make me suspect the app crashes, and as I mentioned in docker in my local machine it crash
Tried different versions of docker node and all crash the same way
Running as a node server (no docker) everything works fine
let's see your dockerfile
i see you are doing a whole lot of stuff that isnt absolutely necessary, please get a minimal dockerfile working first
wait do you really need a dockerfile to make astro work on railway?
no
no
I was using a dockerfiie for portability in case I want to go another place. But will try without a dockerfiie
How do I force it to be a node server? It automatically detects the dockerfiie and uses it
remove or rename the dockerfile
I changed to custom build and run commands. Does that suffice ? The problem persists
what are your custom build and start commands?
Just removed the dockerfile. The build now fails.
My custom build is:
pnpm build
My custom run is
node ./dist/server/entry.mjs
Now that I removed the dockerfile it fails to build:
full build logs please https://bookmarklets.up.railway.app/log-downloader/
Maybe I need to run
pnpm install
first? Or does that happen automatically?fix your typo please, i dont understand the question
wow, chrome made having bookmarklets very difficult
its just drag and drop?
i use chrome
remove the install command from your build command please
Removed, do I re-export the logs?
yes please
what node version are you using locally
18
18.18.0
you do use pnpm locally right
yes
you think I'm installing mac-scpecific stuff?
there are no errors duing the install phase
can you run
pnpm build
locally without issues?no, there are not
Yes, I do it like 5 times a day because it's convenient
are you making sure node_modules and the built files arent making it into your repo
Wait, let me test something locally
Yes, both configs build locally fine
Yes, they are all gitignored (shaded/dark files are gitignored)
you ran a different build command than what you are telling railway to run
I tested both locally
Gonna try
pnpm build -f astro.node.config.ts
on railway
Same errorthis error wouldnt be isolated to railway, have you tried searching for solutions to the error?
Is the bookmark the only way to download the logs?
Gonna give build a try in a lxc container
unless you want to use railway's api directly, yes
Then in my vps
I isolated the problem to be an issue with Astro hybrid mode. For some reason, when running on hybrid mode is not following the normal flow for pages that are not found, and crashes. Using server mode doesn't suffer from that problem