Bun static site
reallysnazzy
HOBBYOP

a month ago

I have a Bun static site that I'm trying to use on Railway. I was able to get it to detect how to build Bun by adding 'bun run build' start command in the UI, but not able to get it to host the static site for me. AI seems to think it will automatically detect it, but it isn't. Do I need to setup a dockerfile to run Caddy to host these, or can Railway do this for me?

Solved$10 Bounty

24 Replies

reallysnazzy
HOBBYOP

a month ago

I tried adding a public Railway subdomain, but no luck. Getting an error message


reallysnazzy
HOBBYOP

a month ago

Screenshot_2026-04-06_18-36-18.png

Attachments


Did you map the port correctly?


Make sure the port your site is hosted on is the same port your URL is mapped to.


reallysnazzy
HOBBYOP

a month ago

I did port 80


reallysnazzy
HOBBYOP

a month ago

Let me try 443


reallysnazzy
HOBBYOP

a month ago

No luck with 443 either.


Well this depends on what port Bun is using to host the site.


a month ago

You have to set the PORT env variable to match


a month ago

Lemme find docs


reallysnazzy
HOBBYOP

a month ago

Bun isn't hosting the site, I'm building static html files using bun


-# That's if Bun uses PORT no?



You'll need some kind of proxy (eg, Nginx) to forward traffic to the site if nothing's hosting your site right now.


reallysnazzy
HOBBYOP

a month ago

How can I configure Caddy or Nginx to do this? I tried using Caddy template, but I couldn't figure out how to feed the build to Caddy


a month ago

Oh alright in that case you might need to setup a proxy like caddy or nginx to actually serve the content.


Well, one way is to use a Dockerfile.


a month ago

Alternatively



a month ago

You could use a package like this or the bun server to serve your dist folder


That too.
There are lots of ways to host a static site.



reallysnazzy
HOBBYOP

a month ago

I ended up using Dockerfile with caddy


a month ago

Good choice!


Status changed to Open medim about 1 month ago


Status changed to Solved brody about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...