diff --git a/src/server.ts b/src/server.ts index 9bc8928..65383ea 100644 --- a/src/server.ts +++ b/src/server.ts @@ -120,6 +120,10 @@ app.set("trust proxy", Number.isFinite(trustProxyHops) && trustProxyHops >= 0 ? // Previously used `process.env.API_URL || '*'` which opened the API to any origin. // The API's own public origin is always allowed so the Swagger UI served by this // server keeps working even if ALLOWED_ORIGINS is missing on the host. +// Apple Sign In's callback uses response_mode=form_post, so the browser POSTs the +// auth code from appleid.apple.com with an Origin header. Without trusting that +// origin the CORS middleware 403s the callback before it reaches the controller. +const APPLE_OAUTH_ORIGIN = "https://appleid.apple.com"; const allowedOrigins = Array.from( new Set( [ @@ -128,6 +132,7 @@ const allowedOrigins = Array.from( : []), process.env.RENDER_EXTERNAL_URL, process.env.API_URL, + APPLE_OAUTH_ORIGIN, ].filter((o): o is string => Boolean(o)), ), );