From 3e5561cf1df01c8c8825909027e0ea46e6e50e67 Mon Sep 17 00:00:00 2001 From: Kevin Jennison Date: Wed, 20 Jul 2022 13:57:03 -0700 Subject: [PATCH] Hardcode Vercel URL --- .env.development | 3 --- __test__/next.config.test.js | 7 +++---- next.config.js | 8 ++------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.env.development b/.env.development index 14024a79..c3e7a049 100644 --- a/.env.development +++ b/.env.development @@ -58,9 +58,6 @@ COOKIE_SECURE_SAME_SITE_NONE=false ########## URL/Path Configuration ########## -# For local development only. This is set by Vercel in deploys. -NEXT_PUBLIC_VERCEL_URL=http://localhost:3001/ - # Note that the base path is also hardcoded in vercel.json and # next.config.js. NEXT_PUBLIC_URLS_BASE_PATH=/newtab diff --git a/__test__/next.config.test.js b/__test__/next.config.test.js index 97144d78..c7d64b03 100644 --- a/__test__/next.config.test.js +++ b/__test__/next.config.test.js @@ -5,7 +5,6 @@ jest.mock('@sentry/webpack-plugin') jest.mock('@zeit/next-source-maps', () => () => (config) => config) beforeEach(() => { - process.env.NEXT_PUBLIC_VERCEL_URL = 'tab-abc123-gladly-team.vercel.app' process.env.NEXT_PUBLIC_URLS_BASE_PATH = '/newtab' }) @@ -30,15 +29,15 @@ describe('Next.js config', () => { expect.assertions(1) const config = require('../next.config') expect(config.workboxOpts.runtimeCaching[0].urlPattern).toEqual( - /tab-abc123-gladly-team.vercel.app\/newtab.*|https:\/\/prod-tab2017-media.gladly.io\/.*|https:\/\/dev-tab2017-media.gladly.io\/.*|https:\/\/dev-tab2017.gladly.io\/newtab\/.*|https:\/\/tab.gladly.io\/newtab\/.*/ + /.*-gladly-team.vercel.app\/newtab.*|https:\/\/prod-tab2017-media.gladly.io\/.*|https:\/\/dev-tab2017-media.gladly.io\/.*|https:\/\/dev-tab2017.gladly.io\/newtab\/.*|https:\/\/tab.gladly.io\/newtab\/.*/ ) }) - it('throws if the NEXT_PUBLIC_VERCEL_URL environment variable is not set', () => { + it('does not throw if the NEXT_PUBLIC_VERCEL_URL environment variable is not set', () => { expect.assertions(1) delete process.env.NEXT_PUBLIC_VERCEL_URL expect(() => { require('../next.config') - }).toThrow(new Error('Env var "NEXT_PUBLIC_VERCEL_URL" is required.')) + }).not.toThrow() }) }) diff --git a/next.config.js b/next.config.js index e0fbd411..f57c8c92 100644 --- a/next.config.js +++ b/next.config.js @@ -34,18 +34,14 @@ const withSourceMaps = require('@zeit/next-source-maps')({ }) const basePath = process.env.NEXT_PUBLIC_URLS_BASE_PATH || '' -const url = process.env.NEXT_PUBLIC_VERCEL_URL -if (!url) { - throw new Error('Env var "NEXT_PUBLIC_VERCEL_URL" is required.') -} - +const generalizedVercelDomain = '.*-gladly-team.vercel.app' const devAssetsRegex = 'https://prod-tab2017-media.gladly.io/.*' const prodAssetsRegex = 'https://dev-tab2017-media.gladly.io/.*' const devCloudFrontRegex = 'https://dev-tab2017.gladly.io/newtab/.*' const prodCloudFrontRegex = 'https://tab.gladly.io/newtab/.*' const cachingRegex = new RegExp( - `${url}${basePath}.*|${devAssetsRegex}|${prodAssetsRegex}|${devCloudFrontRegex}|${prodCloudFrontRegex}` + `${generalizedVercelDomain}${basePath}.*|${devAssetsRegex}|${prodAssetsRegex}|${devCloudFrontRegex}|${prodCloudFrontRegex}` ) // Use the SentryWebpack plugin to upload the source maps during build.