Allow types.ruff.rs for red-knot playground (#17358)

This commit is contained in:
Charlie Marsh 2025-04-11 12:56:03 -04:00 committed by GitHub
parent 7d11ef1564
commit 4bfdf54d1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,6 +31,8 @@ const PRODUCTION_HEADERS = {
"Access-Control-Allow-Origin": "https://play.ruff.rs",
};
const ALLOWED_DOMAINS = ["https://playknot.ruff.rs", "https://types.ruff.rs"];
export default {
async fetch(
request: Request,
@ -40,8 +42,12 @@ export default {
const { DEV, PLAYGROUND } = env;
const headers = DEV ? DEVELOPMENT_HEADERS : PRODUCTION_HEADERS;
if (!DEV && request.headers.get("origin") === "https://playknot.ruff.rs") {
headers["Access-Control-Allow-Origin"] = "https://playknot.ruff.rs";
if (!DEV) {
const origin = request.headers.get("origin");
if (origin && ALLOWED_DOMAINS.includes(origin)) {
headers["Access-Control-Allow-Origin"] = origin;
}
}
switch (request.method) {