Skip to content

Commit

Permalink
fix: check if window object exists for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bompo committed Nov 4, 2024
1 parent bc7e2b6 commit d27f460
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/NovaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export class NovaClient {

private getInitialHeaders(config: NovaClientConfig): Record<string, string> {
const headers: Record<string, string> = {}
if (config.instanceUrl === window.location.origin) {
if (
typeof window !== "undefined" &&
config.instanceUrl === window.location.origin
) {
return headers // No authorization needed if deployed on the same instance
}
if (config.accessToken) {
Expand All @@ -110,7 +113,10 @@ export class NovaClient {
}

private async fetchTokenIfNeeded(): Promise<string | null> {
if (this.config.instanceUrl === window.location.origin) {
if (
typeof window !== "undefined" &&
this.config.instanceUrl === window.location.origin
) {
return null // No token needed if deployed on the same instance
}
if (this.config.accessToken) {
Expand Down

0 comments on commit d27f460

Please sign in to comment.