Skip to content

Middleware: Support for basePath in the app directory #243

Closed
@amannn

Description

@amannn

Currently the middleware assumes that / is the root of the app and works on top of that.

We could adapt it as follows:

  1. Don't hardcode the root URL
  2. All the places where an absolute URL is constructed, the basePath needs to be considered
    urlObj.pathname = urlObj.pathname.replace(`/${locale}`, '');
  3. Somehow the basePath needs to be passed to the middleware. Maybe we could use the plugin that is worked on in feat!: Next.js 13 RSC integration #149 to read it from the Next.js config and then make it automatically available to the middleware (e.g. with webpack.DefinePlugin).

Potentially this could also help to implement region-specific routing, see #243 (comment) and #549

(discussed in #242)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions