Skip to content
Merged
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
5 changes: 5 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand All @@ -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)),
),
);
Expand Down
Loading