Skip to content

Commit

Permalink
Make staging environment work (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
DinerIsmail authored Jan 9, 2025
1 parent 4cd6994 commit bf4760e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions helpers/config.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
7 changes: 4 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
) {
Expand All @@ -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).*)',
],
}

0 comments on commit bf4760e

Please sign in to comment.