[Resolved] How to get Custom Domain CNAME value when using the Public API

patstlouis
PROOP

a month ago

I've created a service with a Custom Domain using the public API. How can my client know which CNAME record to create? Including the cnameCheck and status return values on customDomainCreate mutation is raising issues and it's not clear where to find this information. The customDomainCreate returns the id and edgeId, do I need to make another query to get the record information?

Regards

Solved$20 Bounty

14 Replies

Railway
BOT

a month ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


officialdevgio
FREE

a month ago

The customDomainCreate call only returns the id and edgeId. It doesn’t include the DNS target.

Here’s the process:

  1. Call customDomainCreate and note the id.

  2. Use that id in a follow-up query, like customDomain(id) or by listing domains.

  3. That query will return the CNAME target and status so you know which record the client should set up.

So yes, you need to make another query. The create call provisions the domain, and the fetch call gives you the DNS record.


patstlouis
PROOP

a month ago

Thank you for your input. When I query the customDomain, I have the same behavior. The provided collection provides the following query for this endpoint:

query customDomain($id: String!, $projectId: String!) {
  customDomain(id: $id, projectId: $projectId) {
    __typename
    # cnameCheck
    createdAt
    deletedAt
    domain
    edgeId
    environmentId
    id
    projectId
    serviceId
    # status
    targetPort
    updatedAt
  }
}

Notice the cnameCheck and status are commented out. If I uncomment them, the query returns a 'Problem processing request' message. This is the same behavior as the customDomainCreate mutate function call.

Is there something I'm missing here?


version3034
FREE

a month ago

Hello,

Railway uses edge ID’s so for example <edge-id>.cname.railway.app

Let’s say your edge is is apple_6066.cnam.railway.app

You would set

yourdomain.com CNAM apple_6066.cnam.railway.app


patstlouis
PROOP

a month ago

This doesn't reflect what I'm seeing. When I create the custom domain with the api, I get a edge_id which looks like edge-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. When I go see the custom endpoint created in my dashboard, the record it's asking me to create is for xxxxxxxx.up.railway.app . There is no similarities between these two values. I would like to get the latter values through the API. See picture attached.

Attachments


version3034
FREE

a month ago


version3034
FREE

a month ago

Have you updated your DNS settings to use the values railway provided ?


version3034
FREE

a month ago

I see what your asking..

The API only provides you the edge_id, which doesn’t map to the .up.railway.app domain.

The Dashboard shows xxxxxx.up.railway.app, which is what you need to map your CNAME but there is no way to get that value directly from the API…


patstlouis
PROOP

a month ago

Correct, when looking at the api documentation for both the mutate customDomainCreate and query customDomain, the cnameCheck / status is commented out:
https://www.postman.com/railway-4865/railway/request/ix9woht/customdomain?tab=body
https://www.postman.com/railway-4865/railway/request/7765qy1/customdomaincreate?tab=body

Furthermore, the domains query has both customDomains and serviceDomains commented out:
https://www.postman.com/railway-4865/railway/request/ty9di89/domains?tab=body

Uncommenting any of these values in my API calls returns the error from the server.

I can setup a custom domain from the UI dashboard without any issues, however I want to enable my client to take care of this by communicating this value to my DNS provider's API. It seems to me like returning the CNAME record value from the API isn't currently implemented, which greatly reduces the customDomainCreate call's purpose.

I'm looking for any help in achieving this, since this value is accessible to the UI, there must be a way to fetch it.


officialdevgio

The customDomainCreate call only returns the id and edgeId. It doesn’t include the DNS target.Here’s the process:Call customDomainCreate and note the id.Use that id in a follow-up query, like customDomain(id) or by listing domains.That query will return the CNAME target and status so you know which record the client should set up.So yes, you need to make another query. The create call provisions the domain, and the fetch call gives you the DNS record.

patstlouis
PROOP

a month ago

Have you tested this? Making a separate call gives the same resulting error.


patstlouis

Have you tested this? Making a separate call gives the same resulting error.

version3034
FREE

a month ago

From what I understand, you cannot retrieve the data from the API. You can only see it in your dashboard…

Your best bet would be probably to send an email to team @ railway.com , and see if they can implement this as a one off for you or suggest some other alternative workaround.

I am speculating either it’s designed in such a way for security, to prevent people from creating spam farms and or it’s a backend coding implementation related to how instances are spun up.

But regardless, it’s not something you can get directly from the API. So it’s nothing your doing wrong .


a month ago

Hey there, could you request this as a feature request? This helps us gauge the demand and different usecases, so that our team can pick up what's most requested.

You can write your feature request and view the roadmap here ---> https://station.railway.com/roadmap


patstlouis
PROOP

a month ago


patstlouis
PROOP

a month ago

as pointed out by @brody in this thread, the issue was with how to query the status in the response

https://station.railway.com/feedback/enabling-complete-custom-domain-registra-6470c78b

mutation customDomainCreate($input: CustomDomainCreateInput!) {
    customDomainCreate(input: $input) {
        domain
        edgeId
        id
        status {
            dnsRecords {
                currentValue
                fqdn
                hostlabel
                purpose
                recordType
                requiredValue
                status
                zone
            }
        }
    }
}

Status changed to Solved brody about 1 month ago


Loading...
[Resolved] How to get Custom Domain CNAME value when using the Public API - Railway Help Station