From f27901c4530f2d99a03ffe8a49cca98945d1cf47 Mon Sep 17 00:00:00 2001 From: conico974 Date: Wed, 15 Apr 2026 14:52:44 +0200 Subject: [PATCH] Update deployment ID logic for environment-specific prefixes (#4191) --- packages/gitbook/next.config.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/gitbook/next.config.mjs b/packages/gitbook/next.config.mjs index f9843ed07..d920920b6 100644 --- a/packages/gitbook/next.config.mjs +++ b/packages/gitbook/next.config.mjs @@ -1,11 +1,22 @@ // @ts-check // We don't use the deployment ID yet on 2c, we need to remove it because of https://github.com/opennextjs/opennextjs-aws/issues/1136 -const deploymentId = +let deploymentId = process.env.GITBOOK_RUNTIME === 'cloudflare' ? undefined : process.env.GITBOOK_HEAD_SHA || process.env.GITHUB_SHA || Date.now().toString(); // Needed because we use a custom deployment method i.e. https://vercel.com/docs/skew-protection#custom-deployment-id +const { VERCEL_TARGET_ENV } = process.env; + +// Because preview, staging and prod shares the same SHA, the deployment will fail if we don't prefix it with the environment name. +if (VERCEL_TARGET_ENV === 'preview') { + deploymentId = `t-${deploymentId}`; +} else if (VERCEL_TARGET_ENV === 'staging') { + deploymentId = `s-${deploymentId}`; +} else if (VERCEL_TARGET_ENV === 'production') { + deploymentId = `p-${deploymentId}`; +} + /** * @type {import('next').NextConfig} */