supertokens-auth-react icon indicating copy to clipboard operation
supertokens-auth-react copied to clipboard

Can't use next.js basePath configuration attribue

Open Twister42 opened this issue 4 months ago • 0 comments

Hello,

first things first : i've made a project with all the latest version of next and supertokens to test this, so you can consider the current version as the one having an issue 🙂

When you set a basePath for nextJs everything get prefixed and it messes up with Supertokens' paths.

If you set up a simple project with the following parameters nothing works :

export const appInfo = {
  appName: 'App',
  websiteDomain: 'http://localhost:3000',
  apiDomain:  'http://localhost:3000',
  apiBasePath: '/prefix/auth',
  websiteBasePath: "/prefix/auth",
};

next.config.ts :

const moduleExports = {
  basePath: '/prefix'
}

When messing with the appInfo, either you get blocked by a path filter in the backend ether you get redirected to /prefix/prefix/auth

 // if the prefix of the URL doesn't match the base path, we skip
if (!path.startsWith(this.appInfo.apiBasePath)) {
    (0, logger_1.logDebugMessage)(
        "middleware: Not handling because request path did not start with config path. Request path: " +
            path.getAsStringDangerous()
    );
    return false;
}

I can't find a way to make it work

Twister42 avatar Jul 29 '25 06:07 Twister42