"issuerBaseURL" must be a valid uri

I’m getting the error "issuerBaseURL" must be a valid uri when using the nextjs-auth0 SDK in production (but not in dev).

I have AUTH0_ISSUER_BASE_URL in my env variables and it has the format https://<MY_DOMAIN>.auth0.com.

Here is the full error:

TypeError: "issuerBaseURL" must be a valid uri
    at Object.get (/app/node_modules/@auth0/nextjs-auth0/dist/auth0-session/get-config.js:147:15)
    at Object.getConfig (/app/node_modules/@auth0/nextjs-auth0/dist/config.js:66:38)
    at Object.initAuth0 (/app/node_modules/@auth0/nextjs-auth0/dist/index.js:22:23)
    at getInstance (/app/node_modules/@auth0/nextjs-auth0/dist/index.js:18:24)
    at handleAuth (/app/node_modules/@auth0/nextjs-auth0/dist/index.js:124:18)
    at Object.4987 (/app/.next/server/pages/api/auth/[...auth0].js:15:127)
    at __webpack_require__ (/app/.next/server/webpack-runtime.js:25:42)
    at __webpack_exec__ (/app/.next/server/pages/api/auth/[...auth0].js:49:52)
    at /app/.next/server/pages/api/auth/[...auth0].js:50:28
    at Object.<anonymous> (/app/.next/server/pages/api/auth/[...auth0].js:53:3)

And here is my [..auth0.js] file:

import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';

export default handleAuth({
    async login(req, res) {
      try {
        await handleLogin(req, res, {
          authorizationParams: {
            audience: process.env.AUTH0_AUDIENCE,
            // Add the `offline_access` scope to also get a Refresh Token
            scope: 'openid profile email'
          }
        });
      } catch (error) {
        res.status(error.status || 400).end(error.message);
      }
    }
  });

Any thoughts on what I’m doing wrong here?

I’m using:
Next.js v11.0.1
nextjs-auth0 v.1.5.0

Thank you in advance

I had the same issue and removed the " from the env variable and that worked for me

I’m using:
nextjs-auth0 ^1.4.2
next 12.0.3

I hope it helps

1 Like

Thanks for sharing that with the rest of community Chris!

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