nuxt-oidc-auth: Token Request Failed - Callback route not found

I am having an issue getting this to run in my Nuxt project using the generic OIDC provider (with AWS Cognito).

The auth flow initializes fine and I get to the Cognito login page fine. When redirected back to the callback page, I get a 500: Token request failed error. Looking at the console logs, I see that its failing to find the route for the callback, even though I have the middleware registered. I have compared everything else I can think of to the playground project in the repository.

[nuxt] error caught during app initialization Error: Page not found: /auth/oidc/callback?

Package versions: Nuxi: ^3.12.0 Nuxt: ^3.12.4 nuxt-oidc-auth: ^0.12.0

Nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default {
	modules: [
    "nuxt-oidc-auth",
  ],
	googleFonts: {
		families: {
			Inter: true,
		},
	},
	tailwindcss: {
		jit: true,
	},
  runtimeConfig: {
    public: {
      apiBaseUrl: process.env.API_BASE_URL,
    },
  },
  imports: {
    dirs: ['./utils'],
  },
  oidc: {
    middleware: {
      globalMiddlewareEnabled: true,
    },
    defaultProvider: 'oidc',
    providers: {
      oidc: {
        clientId: '***',
        clientSecret: '***',
        responseType: 'code',
        pkce: true,
        authorizationUrl: 'https://***.auth.us-east-1.amazoncognito.com/oauth2/authorize',
        tokenUrl: 'https://***.auth.us-east-1.amazoncognito.com/oauth2/token',
        userinfoUrl: 'https://***.auth.us-east-1.amazoncognito.com/oauth2/userInfo',
        redirectUri: 'http://localhost:3000/auth/oidc/callback',
        scope: [ 'openid', 'profile' ],
        responseMode: 'query',
      },
    },
  },
  nitro: {
    preset: 'node-server',
    storage: { // Local file system storage for demo purposes
      oidc: {
        driver: 'fs',
        base: 'oidcstorage'
      }
    }
  },
};

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Hello @itpropro Thank you very much. I updated to the newest version, switched to Zitadel as provider and cleaned out my old config. Working perfectly! Do you wan’t me to test anything special for you? Best regards

That’s great to hear! I tested it with the PKCE and Code flow as well as the logout redirect features, so if you find something in the future, feel free to open another issue.

Hello @itpropro Thank you very much. I updated to the newest version, switched to Zitadel as provider and cleaned out my old config. Working perfectly! Do you wan’t me to test anything special for you? Best regards

Hi @itpropro

Thank you very much. You saved me a lot of trail & error this weekend. I couldn’t install the newest version yet but with your hints above it is working perfectly. I even don’t get the missing callback warning any more… I haven’t changed anything except added the token attributes in the config.

I will keep testing until I get the hang of it all a little better.

Thanks again!

best regards

I just released the new version. It also handles some configurations that were necessary to get the logout redirection to work correctly. Please test out the new provider and give some feedback on how that one works.

@itpropro sorry for the delay. Here’s a screenshot of the relevant config for the callback:

image

If meanwhile you solve this issue please tell us how. I’m also with the same problem and cant figure it out. Thanks a lot.

Would you mind open a separate issue for the OIDC provider you are trying it with and some details?

Hey itpropro, thanks for answering. I have opened a issue talking about this and i found a solution, still having problems but at least the 500 dissappeard. You can check it: Title: Token request failed - [nuxt-oidc-auth]: [POST] “https://github.com/login/oauth/access_token”: <no response> fetch failed

Thanks a lot