Next.js Discord

Discord Forum

How to get the wildcard subdomain host?

Unanswered
Pollock posted this in #help-forum
Open in Discord
PollockOP
Hi, I am using Vercel.
I pointed a wildcard (apex domain) and I used this code in my middleware
  if (request.nextUrl.href.indexOf('/dashboard') == -1) {
    return NextResponse.next({
      headers: {
        url: request.headers.get('x-forwarded-host') || request.headers.get('host')!
      }
    });
  }


But instead of getting the subdomain URL, I am getting the internal host URL "docubot-h3ptqqeq0-listinai.vercel.app"
Is there any way to get passed this?

0 Replies