From e75ec8b7e58bf2d31a64f9cdfbbf5637d4f77b57 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 16 Sep 2026 18:12:36 -0600 Subject: [PATCH] fix: include deployment id in the webpack cache key next/font bakes Vercel's ?dpl= skew-protection query into the CSS url()s at build time, but Next's webpack cache key does not include the deployment id. With the restored .next/cache the CSS keeps the previous deployment's id while the HTML preloads use the new one, so every font downloads twice. --- next.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/next.config.js b/next.config.js index 2603ca187..72ec05ca2 100644 --- a/next.config.js +++ b/next.config.js @@ -32,6 +32,18 @@ const nextConfig = { permanent: false } ]; + }, + // Vercel's skew protection appends `?dpl=` to asset URLs. + // `next/font` bakes that query into the CSS `url()`s at build time, but + // Next's webpack cache key ignores the deployment id, so a restored + // `.next/cache` re-emits CSS with the previous deployment's id and every + // font downloads twice (once per id). Fold the id into the cache key. + webpack(config) { + const deploymentId = process.env.NEXT_DEPLOYMENT_ID; + if (deploymentId && config.cache) { + config.cache.version = `${config.cache.version}|${deploymentId}`; + } + return config; } };