AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
570 stars 152 forks source link

Issue with migration to NextJS App Router #1361

Closed swaroopar closed 1 month ago

swaroopar commented 1 month ago

Issue and Steps to Reproduce

Hi Team, need some help here. We have a working CRA based app and are currently migrating it to NextJS App router. The approach is to go step-by-step as described here - https://nextjs.org/docs/app/building-your-application/upgrading/from-create-react-app

But the callback just shows an empty page. I see browser sending a request back to server with the callback URI but there is nothing to be served.

Any tips on how can this be handled with app-router? Important is, we are in the initial phase of migration and all routes are still handled by react-router. I have tried the following things already.

  1. Wrote an app router to handle the callback URL which does the reroute, but this keeps loading the login page since the callback is not executed and the login data is not stored.
  2. Used customHistory but no luck.

Code can be found on this branch - https://github.com/swaroopar/xpanse-ui/blob/feature/migrateToNextJS/src/App.tsx#L56 start the app - https://github.com/swaroopar/xpanse-ui/blob/feature/migrateToNextJS/package.json#L28 test login - user-only/User@1234 Any inputs will be very helpful.

Versions

7.22.4

Screenshots

image

Expected

Login callback redirects to previous page.

Actual

Redirect does not happen.

Additional Details

swaroopar commented 1 month ago

Hi Team, i found the issue. I had by mistake provided the same URL for redirect and for silent redirect URL. This was causing the issue. 🤦‍♂️

The issue can be closed.