Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fix issue with force SSL redirects.

Mike Cao3717b0e88807
diff --git a/pages/_middleware.js b/pages/_middleware.js
index 94d88360e..64dce867c 100644
--- a/pages/_middleware.js
+++ b/pages/_middleware.js
@@ -1,12 +1,13 @@
import { NextResponse } from 'next/server';
function redirectHTTPS(req) {
+ const host = req.headers.get('host');
if (
process.env.FORCE_SSL &&
- !req.headers.get('host').includes('localhost') &&
- req.nextUrl.protocol !== 'https'
+ process.env.NODE_ENV === 'production' &&
+ req.nextUrl.protocol === 'http:'
) {
- return NextResponse.redirect(`https://${req.headers.get('host')}${req.nextUrl.pathname}`, 301);
+ return NextResponse.redirect(`https://${host}${req.nextUrl.pathname}`, 301);
}
}