CustomDomain
Source:
src/Railway/CustomDomain.ts
A Railway.CustomDomain is a user hostname on a CustomDomainService.
Railway issues a Let’s Encrypt certificate once DNS is verified.
Attach a hostname
Section titled “Attach a hostname”Pass the parent Service, the environment id, and the hostname. Yield the
CustomDomain next to the Service. Point DNS at the values in
verificationDnsHost / verificationToken.
const site = yield* Railway.Project("Site");const api = yield* Railway.Service("Api", { project: site, image: "hashicorp/http-echo",});const www = yield* Railway.CustomDomain("Www", { service: api, environment: site, domain: "www.example.com",});Target port
Section titled “Target port”targetPort is optional and updates in place. Railway’s edge forwards
HTTPS on 443 to this port on the Service.
const www = yield* Railway.CustomDomain("Www", { service: api, environment: site, domain: "www.example.com", targetPort: 8080,});Module-scope declarations
Section titled “Module-scope declarations”Declare the CustomDomain once. Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";import { Api } from "./api.ts";import { Site } from "./project.ts";
export const Www = Railway.CustomDomain("Www", { service: Api, environment: Site, domain: "www.example.com",});