Skip to content

fix(nextjs,react): console noise on sign-out, social login and profile popup; configurable log level - #545

Merged
DonOmalVindula merged 4 commits into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-external-navigation
Sep 5, 2026
Merged

fix(nextjs,react): console noise on sign-out, social login and profile popup; configurable log level#545
DonOmalVindula merged 4 commits into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-external-navigation

Conversation

@DonOmalVindula

@DonOmalVindula DonOmalVindula commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Purpose

Two console errors reported while testing the released 0.3.31 line in a Next.js app:

  1. Signing out (and any redirect to a hosted identity-server page) logged CORS and "Failed to fetch RSC payload" errors, even though the navigation eventually succeeded.
  2. Opening the profile popup from the user dropdown logged "Blocked aria-hidden on an element because its descendant retained focus".

Changes

Next.js: cross-origin redirects

  • Add navigateTo(router, url): uses window.location.assign when url is cross-origin and router.push otherwise.
  • Route all redirects in the client AsgardeoProvider (OAuth callback redirect, signInUrl, afterSignInUrl, signUpUrl, afterSignUpUrl, afterSignOutUrl) through it.
  • Unit tests for the helper.

The app router can only render this application's routes. Given an external URL it first fetches it as an RSC payload, which the browser blocks (no CORS headers on the identity server's logout endpoint), and then falls back to a full navigation. The fallback is why sign-out still worked; the errors were the cost.

React: dialog focus

  • The dialog's FloatingFocusManager marks everything outside the dialog aria-hidden, but initialFocus={-1} left focus on the trigger button inside the now-hidden page header. The dialog container now receives focus on open (initialFocus={context.refs.floating} plus tabIndex={-1}). The first input is still not auto-focused.

Next.js: spurious "Authentication failed" on social login

  • The embedded flows open the provider in a popup named oauth_popup and read code/state from that window themselves. The client provider also ran its OAuth callback handler inside that popup, tried to exchange a code belonging to the embedded flow, and logged "Authentication failed" although the login completed. The handler now skips that window.

Next.js: configurable log level

  • The server-side logger was hardcoded to error, which hid the warning that explains why a profile fell back to the ID token claims. ASGARDEO_LOG_LEVEL (debug | info | warn | error, default error) now selects the level; documented in the README.

One changeset covers both packages.

Testing

  • @asgardeo/nextjs and @asgardeo/react unit tests pass.
  • Verified against the reporter's Next.js app on the nexus2026 tenant: sign in, sign out with zero console errors, user lands on the app signed out; after opening the profile popup the focused element is the dialog content (it was the dropdown trigger outside the dialog with 0.25.9).

The client provider handed every redirect to the Next.js app router, including
the identity server's hosted sign-in, sign-up and logout URLs. The router can
only render routes of this application, so for those it first requested the URL
as a React Server Components payload, which the browser blocked with a CORS
error, and only then fell back to a normal navigation. Sign-out therefore
worked but logged "Failed to fetch RSC payload" and CORS errors every time.

Route the redirects through a small navigateTo helper that uses
window.location.assign for cross-origin URLs and the router for in-app ones.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: b11a0c87-7a33-43e5-a37b-be85d83d0606

📥 Commits

Reviewing files that changed from the base of the PR and between 9dda2c7 and 6600eac.

📒 Files selected for processing (7)
  • .changeset/console-noise-fixes.md
  • packages/nextjs/README.md
  • packages/nextjs/src/client/contexts/Asgardeo/AsgardeoProvider.tsx
  • packages/nextjs/src/utils/__tests__/navigateTo.test.ts
  • packages/nextjs/src/utils/logger.ts
  • packages/nextjs/src/utils/navigateTo.ts
  • packages/react/src/components/primitives/Dialog/Dialog.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…n the hidden trigger

FloatingFocusManager marks everything outside an open dialog aria-hidden. With
initialFocus={-1} the focus stayed on the element that opened the dialog, e.g.
the user dropdown trigger in a page header, so a focused element was hidden
from assistive technology and Chrome logged "Blocked aria-hidden on an element
because its descendant retained focus" whenever the profile popup opened.

Focus the dialog container itself on open. This keeps the previous behaviour of
not auto-focusing the first input.
@DonOmalVindula DonOmalVindula changed the title fix(nextjs): use a browser navigation for cross-origin redirects fix(nextjs,react): browser navigation for cross-origin redirects, focus dialogs on open Sep 5, 2026
…make the log level configurable

- The embedded sign-in/sign-up flows open the identity provider in a popup
  named oauth_popup and read code/state from that window's URL themselves.
  The client provider also ran its OAuth callback handler in that popup,
  tried to exchange a code that belonged to the embedded flow, and logged
  "Authentication failed" on every social login even though the flow
  completed.
- The server-side logger was hardcoded to error level, hiding warnings such
  as the SCIM2 profile fallback. ASGARDEO_LOG_LEVEL now selects the level.
@DonOmalVindula DonOmalVindula changed the title fix(nextjs,react): browser navigation for cross-origin redirects, focus dialogs on open fix(nextjs,react): console noise on sign-out, social login and profile popup; configurable log level Sep 5, 2026
@asgardeo-github-bot

Copy link
Copy Markdown

🦋 Changeset detected

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

@DonOmalVindula
DonOmalVindula merged commit 68c7a92 into asgardeo:main Sep 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants