Skip to content

Commit df5c588

Browse files
authored
Fix default redirectMethod for Node.js environments (#1301)
## Summary - Fixes the default `redirectMethod` to check `typeof window !== "undefined"` before defaulting to `"window"` - In Node.js/CLI environments (where `window` is undefined), defaults to `"none"` instead, preventing runtime errors ## Context PR #1253 changed the default `redirectMethod` from `"none"` to `"window"`, but this breaks non-browser environments (Node.js scripts, CLI tools, backend services) that don't have a `window` object. ## Test plan - [ ] Verify existing e2e tests pass (they explicitly set `redirectMethod: "none"`) - [ ] Verify browser usage still defaults to `"window"` - [ ] Verify Node.js usage (e.g. `stack-cli`) defaults to `"none"` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed redirect behavior so client-side redirects continue in browser environments, while non-browser or server-side executions now default to no automatic redirect, avoiding unexpected navigation. Existing platform-specific redirect handling remains unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 4829582 commit df5c588

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ export class _StackClientAppImplIncomplete<HasTokenStore extends boolean, Projec
530530
}
531531

532532
this._tokenStoreInit = resolvedOptions.tokenStore;
533-
this._redirectMethod = resolvedOptions.redirectMethod || "window";
533+
this._redirectMethod = resolvedOptions.redirectMethod || (isBrowserLike() ? "window" : "none");
534534
this._redirectMethod = resolvedOptions.redirectMethod || "nextjs"; // THIS_LINE_PLATFORM next
535535
this._urlOptions = resolvedOptions.urls ?? {};
536536
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};

0 commit comments

Comments
 (0)