Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
fix: middleware rewrite condition
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Nov 6, 2023
1 parent 464c84b commit 9ed22cf
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export async function middleware(req) {
const sessionRequired = ["/account", "/api/account"];
const adminRequired = ["/admin", "/api/admin"];
const adminUsers = process.env.ADMIN_USERS.split(",");

console.log(
`domain used "${hostname}" with path "${reqPathName}"`,
`Request Url "${req.url}"`,
`Req nextUrl "${req.nextUrl.host}"`,
const hostedDomain = process.env.NEXT_PUBLIC_BASE_URL.replace(
/http:\/\/|https:\/\//,
"",
);

// if custom domain + on root path
if (hostname !== req.nextUrl.host && reqPathName === "/") {
if (hostname !== hostedDomain && reqPathName === "/") {
console.log(`custom domain used: "${hostname}"`);

let res;
Expand Down

0 comments on commit 9ed22cf

Please sign in to comment.