srs-api: allowlist both docs origins for /api/stats CORS

This commit is contained in:
Prad Nukala
2026-08-24 19:12:11 -04:00
parent 7213cc1c8a
commit ab5c251952
2 changed files with 7 additions and 3 deletions
+6 -1
View File
@@ -261,8 +261,13 @@ export default {
}
if (path === "/api/stats") {
// The docs serve from both the Pages origin and the custom domain;
// reflect the requesting origin only when it is on the allowlist.
const allowed = env.DOCS_ORIGIN.split(",").map((o) => o.trim());
const origin = request.headers.get("origin");
const cors = {
"access-control-allow-origin": env.DOCS_ORIGIN,
"access-control-allow-origin":
origin && allowed.includes(origin) ? origin : allowed[0]!,
"access-control-allow-methods": "GET",
vary: "Origin",
};