Next.js Discord

Discord Forum

Custom domain added via Domain-API not calling middleware

Unanswered
Pyrenean Mastiff posted this in #help-forum
Open in Discord
Pyrenean MastiffOP
I'm building multi-tenant applications where I'm adding domains via domain API. The added domain is verified successfully.
But while hitting the custom domain, the log is showing in vercel but middleware is not getting called.
Here in the attached image, I've middleware in the application that is logging the ID, but the same middleware is not getting called for the www.geniusmarket... domain that is added via domain API.

Here is what my middleware config looks like,
export const config = {
  matcher: [
    '/((?!api|_next/static|_next/image|images|favicon.ico).*)',
  ],
};


Steps to reproduce it in brief
1. Add the domain to the app via Domain API.
2. Verify the domain in the domain provider by adding the following records,
type: CNAME
name: www
value: cname.vercel-dns.com.
TTL: 1/2 hour

Type: A
Name: @
Value: 76.76.21.21
TTL: 1/2 hour

3. Now while hitting the domain, Chrome will show the error www.example.com redirected you too many times.
4. Also deployment logs show the domain request but middleware is not getting called.

Any help is highly appreciated, thank you in advance 🙏🏻

0 Replies