Skip to content

Commit 56921d4

Browse files
authored
Persist MSAL token in local storage (#172)
1 parent 63a1947 commit 56921d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ui/main.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import "zod-openapi/extend";
2-
import { Configuration, PublicClientApplication } from "@azure/msal-browser";
2+
import {
3+
BrowserCacheLocation,
4+
Configuration,
5+
PublicClientApplication,
6+
} from "@azure/msal-browser";
37
import { MsalProvider } from "@azure/msal-react";
48
import ReactDOM from "react-dom/client";
59

@@ -19,12 +23,13 @@ const msalConfiguration: Configuration = {
1923
postLogoutRedirectUri: `${window.location.origin}/logout`,
2024
},
2125
cache: {
22-
cacheLocation: "sessionStorage",
26+
cacheLocation: BrowserCacheLocation.LocalStorage,
2327
storeAuthStateInCookie: true,
2428
},
2529
};
2630

2731
const pca = new PublicClientApplication(msalConfiguration);
32+
pca.initialize();
2833

2934
ReactDOM.createRoot(document.getElementById("root")!).render(
3035
<MsalProvider instance={pca}>

0 commit comments

Comments
 (0)