How to access the domain name in Next.js (middlewares)?

Hi,
I am trying to setup internationalization in Next 13 based on the domain name. However since Render uses a local URL rewrite, the domain in “request.nextUrl”’ is “localhost” and not the domain requested by user.

Is the initial domain kept in a header or somewhere else?

An environment variable won’t fit as it needs to vary depending on the domain.

This previous answer doesn’t address the issue: NextJS Middleware localhost

It seems the “host” header should help:

But I couldn’t find any official documentation about that.

Would any of these help? https://render.com/docs/environment-variables

John B
Render Support, UTC+1 :uk:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.