Skip to main content

Middleware

The Next.js middleware primarily handles the transformation and routing for locales and langagues.

By default the Next.js application only accepts a single param for locales, the middleware is invoked on every requested to client facing pages and transforms the two parameters into a page re-write that Next.js can accept. The URL to the user has not changed, but under the hood it is different.

For Example:

https://content.rapha.cc/gb/en

# Will be
https://content.rapha.cc/gb-en

It will also read Cookies to try and pick up any language or region Cookies set by rapha.cc.

Non Live Paths​

To hide some paths in production the middleware will redirect to 404 if the page path is in this string. The string can be a whole path, or just the start of a path

For Example:

/clubhouses/

# or to be more specific
/clubhouses/london