railway-domain

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Railway Domain Management

Railway域名管理

Add, view, or remove domains for Railway services.
为Railway服务添加、查看或删除域名。

When to Use

适用场景

  • User asks to "add a domain", "generate a domain", "get a URL"
  • User wants to add a custom domain
  • User asks "what's the URL for my service"
  • User wants to remove a domain
  • 用户要求“添加域名”、“生成域名”、“获取URL”
  • 用户想要添加自定义域名
  • 用户询问“我的服务URL是什么”
  • 用户想要删除域名

Add Railway Domain

添加Railway域名

Generate a railway-provided domain (max 1 per service):
bash
railway domain --json
For a specific service:
bash
railway domain --json --service backend
生成Railway提供的域名(每个服务最多1个):
bash
railway domain --json
针对特定服务:
bash
railway domain --json --service backend

Response

返回结果

Returns the generated domain URL. Service must have a deployment.
返回生成的域名URL。服务必须已部署。

Add Custom Domain

添加自定义域名

bash
railway domain example.com --json
bash
railway domain example.com --json

Response

返回结果

Returns required DNS records:
json
{
  "domain": "example.com",
  "dnsRecords": [
    { "type": "CNAME", "host": "@", "value": "..." }
  ]
}
Tell user to add these records to their DNS provider.
返回所需的DNS记录:
json
{
  "domain": "example.com",
  "dnsRecords": [
    { "type": "CNAME", "host": "@", "value": "..." }
  ]
}
告知用户需将这些记录添加到其DNS服务商处。

Read Current Domains

查看当前域名

Use railway-environment skill to see configured domains, or query directly:
graphql
query domains($envId: String!) {
  environment(id: $envId) {
    config(decryptVariables: false)
  }
}
Domains are in
config.services.<serviceId>.networking
:
  • serviceDomains
    - Railway-provided domains
  • customDomains
    - User-provided domains
使用railway-environment技能查看已配置的域名,或直接查询:
graphql
query domains($envId: String!) {
  environment(id: $envId) {
    config(decryptVariables: false)
  }
}
域名位于
config.services.<serviceId>.networking
中:
  • serviceDomains
    - Railway提供的域名
  • customDomains
    - 用户提供的域名

Remove Domain

删除域名

Use railway-environment skill to remove domains:
使用railway-environment技能删除域名:

Remove custom domain

删除自定义域名

json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "customDomains": { "<domainId>": null }
      }
    }
  }
}
json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "customDomains": { "<domainId>": null }
      }
    }
  }
}

Remove railway domain

删除Railway域名

json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "serviceDomains": { "<domainId>": null }
      }
    }
  }
}
Then use railway-environment skill to apply and commit the change.
json
{
  "services": {
    "<serviceId>": {
      "networking": {
        "serviceDomains": { "<domainId>": null }
      }
    }
  }
}
随后使用railway-environment技能应用并提交更改。

CLI Options

CLI选项

FlagDescription
[DOMAIN]
Custom domain to add (omit for railway domain)
-p, --port <PORT>
Port to connect
-s, --service <NAME>
Target service (defaults to linked)
--json
JSON output
标志描述
[DOMAIN]
要添加的自定义域名(省略则生成Railway域名)
-p, --port <PORT>
要连接的端口
-s, --service <NAME>
目标服务(默认使用已关联的服务)
--json
JSON格式输出

Composability

组合性

  • Read domains: Use railway-environment skill
  • Remove domains: Use railway-environment skill
  • Apply removal: Use railway-environment skill
  • Check service: Use railway-service skill
  • 查看域名:使用railway-environment技能
  • 删除域名:使用railway-environment技能
  • 应用删除操作:使用railway-environment技能
  • 检查服务:使用railway-service技能

Error Handling

错误处理

No Service Linked

未关联服务

No service linked. Use --service flag or run `railway service` to select one.
No service linked. Use --service flag or run `railway service` to select one.

Domain Already Exists

域名已存在

Service already has a railway-provided domain. Maximum 1 per service.
Service already has a railway-provided domain. Maximum 1 per service.

No Deployment

未部署服务

Service has no deployment. Deploy first with `railway up`.
Service has no deployment. Deploy first with `railway up`.

Invalid Domain

无效域名

Invalid domain format. Use a valid domain like "example.com" or "api.example.com".
Invalid domain format. Use a valid domain like "example.com" or "api.example.com".