Custom Public Domain without going into Railway Console
atjain03
HOBBYOP

5 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 "$PROJECT_ID" --environment "$BASE_ENV_ID"

railway environment new pr-${PR_NUM} --duplicate "$BASE_ENV_ID" || true

railway up

--service "$SERVICE_NAME"

--environment "pr-$PR_NUM"

--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

5 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


5 months ago

I'm not sure though


atjain03
HOBBYOP

5 months ago

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


atjain03
HOBBYOP

5 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?


5 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

5 months ago

What do you mean by that?


atjain03
HOBBYOP

5 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?


5 months ago

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


atjain03
HOBBYOP

5 months ago

What is a service domain?


5 months ago

*.up.railway.app


atjain03
HOBBYOP

5 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

5 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


5 months ago

Try using railway domain


5 months ago

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


atjain03
HOBBYOP

5 months ago

Hmmm okay. Are there docs for railway domain?


5 months ago

railway domain --help


Status changed to Solved medim 5 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...