Microsoft-authentication-library-for-js: ReferenceError: window is not defined break SSR

Created on 29 Jul 2020  路  5Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

Please follow the issue template below. Failure to do so will result in a delay in answering your question.

Library

Important: Please fill in your exact version number above, e.g. [email protected].

Framework

n/a

Description

When trying to SSR the code, window not being defined causes the SSR to fail

Error Message

ReferenceError: window is not defined
    at Function.BrowserUtils.getBrowserNetworkClient (PATH_TO_PROJECT/node_modules/@azure/msal-browser/src/utils/BrowserUtils.ts:67:9)

Security

  • [ ] Is this issue security related?

Regression

  • [x] Did this behavior work before?
    Version:
    1.3

    MSAL Configuration

n/a

Reproduction steps

import MSAL and try SSR'ing

Expected behavior

the code should be more sensitive to window not being defined

Browsers/Environment

node. Yes, I know this a browser-based package, trying to SSR for the browser! Perhaps delaying the call that checks for window (or probably fetch) until runtime would help.

Thanks!

bug known-issue msal-browser

All 5 comments

@mbrevda This is a known issue that we intend to fix. We will follow up when we have done so.

I hate to ask, but can you give a unit of measure for an ETA (days/weeks/months)?

@mbrevda Unfortunately, we are not able to give a more specific timeline yet, but we would like to have this fixed soon.

@mbrevda There is now a PR open to fix this scenario, and will be included in an upcoming release of MSAL.js v2. This issue will be updated when that PR has been accepted and merged.

I saw, thanks for pointing it out! Looking forward to the release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  路  3Comments

Calamari picture Calamari  路  3Comments

lecaillon picture lecaillon  路  3Comments

atvoid picture atvoid  路  3Comments

yakimko picture yakimko  路  3Comments