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?
16 Replies
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
2 months ago
I'm not sure though
How will that work? It needs to create a new url for the PR environment to make it different
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?
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.
@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?
2 months ago
It needs a service domain; we don't support custom domains in cloned environments.
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.
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
2 months ago
Try using railway domain
2 months ago
You would still have to manually set the domain up with your registrar, though.
2 months ago
railway domain --help
Status changed to Solved medim • 2 months ago