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

Commit

Permalink
fix: more debugging for custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Nov 6, 2023
1 parent cb5a6f9 commit 2211e1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function middleware(req) {
const adminRequired = ["/admin", "/api/admin"];
const adminUsers = process.env.ADMIN_USERS.split(",");

console.log(`domain used "${hostname}" with path "${reqPathName}"`);
// if custom domain + on root path
if (hostname !== req.nextUrl.host && reqPathName === "/") {
console.log(`custom domain used: "${hostname}"`);
Expand Down Expand Up @@ -54,7 +55,7 @@ export async function middleware(req) {
profile.settings.domain === hostname
) {
console.log(
`custom domain matched "${hostname}" for username "${profile.username}"`,
`custom domain matched "${hostname}" for username "${profile.username}" (protocol: "${protocol}"))`,
);
// if match found rewrite to custom domain and display profile page
return NextResponse.rewrite(
Expand All @@ -64,6 +65,8 @@ export async function middleware(req) {
),
);
}

console.error(`custom domain NOT matched "${hostname}"`);
}

// if not in sessionRequired or adminRequired, skip
Expand Down

0 comments on commit 2211e1c

Please sign in to comment.