Add a custom domain to the service with the provided ID.
1
//native
2
type Render = {
3
apiKey: string
4
}
5
/**
6
* Add custom domain
7
* Add a custom domain to the service with the provided ID.
8
9
*/
10
export async function main(auth: Render, serviceId: string, body: { name: string }) {
11
const url = new URL(`https://api.render.com/v1/services/${serviceId}/custom-domains`)
12
13
const response = await fetch(url, {
14
method: 'POST',
15
headers: {
16
'Content-Type': 'application/json',
17
Authorization: 'Bearer ' + auth.apiKey
18
},
19
body: JSON.stringify(body)
20
})
21
if (!response.ok) {
22
const text = await response.text()
23
throw new Error(`${response.status} ${text}`)
24
25
return await response.json()
26
27