//native
type Render = {
apiKey: string
}
/**
* Replace header rules
* Replace all header rules for a particular service with the provided list.
**This deletes all existing header rules for the service that aren't included in the request.**
*/
export async function main(
auth: Render,
serviceId: string,
body: { path: string; name: string; value: string }[]
) {
const url = new URL(`https://api.render.com/v1/services/${serviceId}/headers`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago