Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ The production CSP admits the exact validated `NEXT_PUBLIC_GATEWAY_URL`; a real
Production build pins that value to `https://gateway.trycheatcode.com`, while optimized
local QA can use its loopback Wrangler origin.
Production additionally admits only Vercel's exact immutable deployment origin.
Google and other social authentication uses Clerk's full-page redirect flow. The callback therefore
finishes through one authoritative navigation instead of a popup attempting to replace the anonymous
client tree after its server identity has changed. Production can keep `Cross-Origin-Opener-Policy`
at `same-origin`; no authentication flow depends on a cross-origin opener relationship.

## Deploy

Expand Down
2 changes: 1 addition & 1 deletion apps/web/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const nextConfig = {
{
headers: [
{ key: "Content-Security-Policy", value: CONTENT_SECURITY_POLICY },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin-allow-popups" },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
{ key: "Origin-Agent-Cluster", value: "?1" },
{ key: "Permissions-Policy", value: "camera=(), geolocation=(), microphone=()" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/auth/auth-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { clerkAuthAppearance } from "./clerk-auth-appearance";

export type AuthMode = "sign-in" | "sign-up";

// OAuth changes the authenticated server identity. A full-page redirect gives Clerk and Next.js
// one authoritative navigation instead of reconciling a popup callback into an anonymous tree.
const AUTH_OAUTH_FLOW = "redirect" as const;

interface AuthModalProps {
open: boolean;
id?: string | undefined;
Expand Down Expand Up @@ -75,15 +79,15 @@ function AuthModalContent({
appearance={clerkAuthAppearance}
fallbackRedirectUrl={redirectPath}
forceRedirectUrl={redirectPath}
oauthFlow="popup"
oauthFlow={AUTH_OAUTH_FLOW}
routing="hash"
/>
) : (
<SignUp
appearance={clerkAuthAppearance}
fallbackRedirectUrl={redirectPath}
forceRedirectUrl={redirectPath}
oauthFlow="popup"
oauthFlow={AUTH_OAUTH_FLOW}
routing="hash"
/>
)}
Expand Down