Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: vercel integration custom envs

Daniel Hougaard5391bcd3b2e2
diff --git a/backend/src/services/integration-auth/integration-app-list.ts b/backend/src/services/integration-auth/integration-app-list.ts
index 1260378957..df61411dd1 100644
--- a/backend/src/services/integration-auth/integration-app-list.ts
+++ b/backend/src/services/integration-auth/integration-app-list.ts
@@ -134,7 +134,15 @@ const getAppsHeroku = async ({ accessToken }: { accessToken: string }) => {
* Return list of names of apps for Vercel integration
* This is re-used for getting custom environments for Vercel
*/
-export const getAppsVercel = async ({ accessToken, teamId }: { teamId?: string | null; accessToken: string }) => {
+export const getAppsVercel = async ({
+ accessToken,
+ teamId,
+ includeCustomEnvironments = false
+}: {
+ teamId?: string | null;
+ accessToken: string;
+ includeCustomEnvironments?: boolean;
+}) => {
const apps: Array<{ name: string; appId: string; customEnvironments: Array<{ slug: string; id: string }> }> = [];
const limit = "20";
@@ -145,12 +153,6 @@ export const getAppsVercel = async ({ accessToken, teamId }: { teamId?: string |
projects: {
name: string;
id: string;
- customEnvironments?: {
- id: string;
- type: string;
- description: string;
- slug: string;
- }[];
}[];
pagination: {
count: number;
@@ -159,6 +161,20 @@ export const getAppsVercel = async ({ accessToken, teamId }: { teamId?: string |
};
}
+ const getProjectCustomEnvironments = async (projectId: string) => {
+ const { data } = await request.get<{ environments: { id: string; slug: string }[] }>(
+ `${IntegrationUrls.VERCEL_API_URL}/v9/projects/${projectId}/custom-environments`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json"
+ }
+ }
+ );
+
+ return data.environments;
+ };
+
while (hasMorePages) {
const params: { [key: string]: string } = {
limit
@@ -180,17 +196,40 @@ export const getAppsVercel = async ({ accessToken, teamId }: { teamId?: string |
}
});
- data.projects.forEach((a) => {
- apps.push({
- name: a.name,
- appId: a.id,
- customEnvironments:
- a.customEnvironments?.map((env) => ({
- slug: env.slug,
- id: env.id
- })) ?? []
+ if (includeCustomEnvironments) {
+ const projectsWithCustomEnvironments = await Promise.all(
+ data.projects.map(async (a) => {
+ const customEnvironments = await getProjectCustomEnvironments(a.id);
+
+ return {
+ ...a,
+ customEnvironments
+ };
+ })
+ );
+
+ console.log(projectsWithCustomEnvironments);
+
+ projectsWithCustomEnvironments.forEach((a) => {
+ apps.push({
+ name: a.name,
+ appId: a.id,
+ customEnvironments:
+ a.customEnvironments?.map((env) => ({
+ slug: env.slug,
+ id: env.id
+ })) ?? []
+ });
});
- });
+ } else {
+ data.projects.forEach((a) => {
+ apps.push({
+ name: a.name,
+ appId: a.id,
+ customEnvironments: []
+ });
+ });
+ }
next = data.pagination.next;
diff --git a/backend/src/services/integration-auth/integration-auth-service.ts b/backend/src/services/integration-auth/integration-auth-service.ts
index 61f7533486..1d9fedde78 100644
--- a/backend/src/services/integration-auth/integration-auth-service.ts
+++ b/backend/src/services/integration-auth/integration-auth-service.ts
@@ -1851,6 +1851,7 @@ export const integrationAuthServiceFactory = ({
const { accessToken } = await getIntegrationAccessToken(integrationAuth, shouldUseSecretV2Bridge, botKey);
const vercelApps = await getAppsVercel({
+ includeCustomEnvironments: true,
accessToken,
teamId
});