From bf4760ed1761e4d9ab190a135b0b9979d465d6a1 Mon Sep 17 00:00:00 2001 From: Diner Date: Thu, 9 Jan 2025 23:31:34 +0000 Subject: [PATCH] Make staging environment work (#246) --- helpers/config.ts | 4 ++-- middleware.ts | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/helpers/config.ts b/helpers/config.ts index f8a17398..6631eec3 100644 --- a/helpers/config.ts +++ b/helpers/config.ts @@ -1,13 +1,13 @@ export const REMOTE_URL = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' - ? `https://${process.env.VERCEL_URL}` + ? 'https://staging.resilienceweb.org.uk' : process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://resilienceweb.org.uk' export const REMOTE_HOSTNAME = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview' - ? process.env.VERCEL_URL + ? 'staging.resilienceweb.org.uk' : process.env.NODE_ENV === 'development' ? 'localhost:3000' : 'resilienceweb.org.uk' diff --git a/middleware.ts b/middleware.ts index 60293215..d0d79d24 100644 --- a/middleware.ts +++ b/middleware.ts @@ -17,8 +17,8 @@ export default function middleware(req: NextRequest) { } let currentHost - if (process.env.VERCEL_ENV === 'preview') { - currentHost = hostname.replace(`.${process.env.VERCEL_URL}`, '') + if (hostname.includes('staging.')) { + currentHost = hostname.replace(`.staging.resilienceweb.org.uk`, '') } else { currentHost = process.env.NODE_ENV === 'production' && process.env.VERCEL === '1' @@ -37,6 +37,7 @@ export default function middleware(req: NextRequest) { hostname === 'localhost:3000' || hostname === 'cambridgeresilienceweb.org.uk' || hostname === 'resilienceweb.org.uk' || + hostname === 'staging.resilienceweb.org.uk' || (process.env.VERCEL_ENV === 'preview' && hostname === process.env.VERCEL_URL) ) { @@ -57,6 +58,6 @@ export default function middleware(req: NextRequest) { */ export const config = { matcher: [ - '/((?!api|admin|_next/static|_next/image|favicon.ico|ph-ingest).*)', + '/((?!api|admin|_next/static|_next/image|favicon.svg|favicon.ico|ph-ingest).*)', ], }