next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Null safe window history state references

Open timtucker-dte opened this issue 1 year ago • 0 comments

For Maintainers

Fixes MSAL issue: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/6851

What?

Make the reference to window.history.state.__PRIVATE_NEXTJS_INTERNALS_TREE in applyUrlHistoryPushReplace null safe.

Why?

All other references in app-router.tsx include checks that would prevent accessing window.history.state when it's null.

applyUrlFromHistoryPushReplace is the only spot missing that type of check.

Current behavior causes exceptions with MSAL redirect handling.

Redirects in MSAL have been broken since windowHistorySupport went live with 14.0.5.

How?

Add an extra null check when referencing: window.history.state.__PRIVATE_NEXTJS_INTERNALS_TREE

timtucker-dte avatar Jan 30 '24 15:01 timtucker-dte