Custom Public Domain without going into Railway Console
atjain03
HOBBYOP

2 months ago

I’ve got a GitHub Actions workflow that spins up a per-PR env on Railway using the CLI. Rough flow:

railway link --project "$PROJECTID" --environment "$BASEENVID" railway environment new pr-${PRNUM} --duplicate "$BASEENVID" || true
railway up \
--service "$SERVICENAME" \ --environment "pr-$PRNUM" \
--detach

Is there any way (via CLI flags or config) to:
1. Set a custom public domain per PR env (e.g. pr-123.myapp.com or 123.preview.myapp.com), or
2. Use a wildcard/custom domain that maps cleanly to these dynamic PR environments?

If that’s not supported directly, is there a recommended workaround people use for PR previews with custom domains?

Solved

16 Replies

medim
MODERATOR

2 months ago

iirc if the service on the base environment has a custom domain then the ones in the PR environment will have one too


medim
MODERATOR

2 months ago

I'm not sure though


atjain03
HOBBYOP

2 months ago

How will that work? It needs to create a new url for the PR environment to make it different


atjain03
HOBBYOP

2 months ago

I'm struggling with it, so I wanted to know if there is some other resource that I could get information from? Someone else I could reach out to?


brody
EMPLOYEE

2 months ago

the service in your cloned environment will only have a domain if the service in your base environment has a service domain.


atjain03
HOBBYOP

2 months ago

What do you mean by that?


atjain03
HOBBYOP

2 months ago

@Brody The service in my base environment does have a custom public URL. But the cloned environment still gives a default Railway URL. Is there any way for me to change that?


brody
EMPLOYEE

2 months ago

It needs a service domain; we don't support custom domains in cloned environments.


atjain03
HOBBYOP

2 months ago

What is a service domain?



atjain03
HOBBYOP

2 months ago

Hmm okay. Is there any other workaround for this? Maybe I don't clone the environment and just create it from scratch.


atjain03
HOBBYOP

2 months ago

Essentially, I just want a programmatic way to create a new environment and set a custom domain without having to use the UI on the dashboard


brody
EMPLOYEE

2 months ago

Try using railway domain


brody
EMPLOYEE

2 months ago

You would still have to manually set the domain up with your registrar, though.


atjain03
HOBBYOP

2 months ago

Hmmm okay. Are there docs for railway domain?


brody
EMPLOYEE

2 months ago

railway domain --help


Status changed to Solved medim 2 months ago


Loading...