Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't store JWT token in an SSR environment #9848

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/medusa-js/src/jwt-token-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class JwtTokenManager {
* Set a store or admin jwt token to be sent with each request.
*/
public registerJwt(token: string, domain: "admin" | "store") {
if (typeof window === 'undefined') {
return;
}

if (domain === "admin") {
this.adminJwt = token;
} else if (domain === "store") {
Expand All @@ -22,6 +26,10 @@ class JwtTokenManager {
* Retrieve the store or admin jwt token
*/
public getJwt(domain: "admin" | "store") {
if (typeof window === 'undefined') {
return;
}

if (domain === "admin") {
return this.adminJwt;
} else if (domain === "store") {
Expand Down
Loading