Skip to content

Commit 255dc99

Browse files
committed
Allow staging preview origins in CORS policy
Add support for *.staging-cambeerfestival.pages.dev domains in the Cloudflare Worker's CORS configuration. This enables branch-based staging deployments to access the API.
1 parent 278cac2 commit 255dc99

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cloudflare-worker/worker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ function getCorsHeaders(request) {
226226
};
227227
}
228228

229+
// Allow Cloudflare Pages staging preview URLs (*.staging-cambeerfestival.pages.dev)
230+
// This includes branch-based staging deployments
231+
// Security note: Same as above - Cloudflare controls the .pages.dev namespace
232+
if (origin.endsWith('.staging-cambeerfestival.pages.dev')) {
233+
return {
234+
'Access-Control-Allow-Origin': origin,
235+
'Access-Control-Allow-Credentials': 'true',
236+
};
237+
}
238+
229239
// Reject all other origins by not including CORS headers
230240
return {};
231241
}

0 commit comments

Comments
 (0)