Created
January 16, 2025 05:29
-
-
Save AshikNesin/e91cddb20617e843a236ac8ed4e5e6c1 to your computer and use it in GitHub Desktop.
Add custom domain to a vercel project using Vercel API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
const AUTH_TOKEN = process.env.VERCEL_AUTH_TOKEN; | |
const projectId = process.env.PROJECT_ID; | |
export const addDomainToProject = async (domain) => { | |
const config = { | |
headers: { | |
Authorization: `Bearer ${AUTH_TOKEN}`, | |
}, | |
}; | |
const payload = { | |
name: domain, | |
}; | |
const url = `https://api.vercel.com/v8/projects/${projectId}/domains`; | |
return axios.post(url, payload, config); | |
}; | |
export const removeDomainFromProject = async (domain) => { | |
const config = { | |
headers: { | |
Authorization: `Bearer ${AUTH_TOKEN}`, | |
}, | |
}; | |
const url = `https://api.vercel.com/v8/projects/${projectId}/domains/${domain}`; | |
return axios.delete(url, config); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment