mirror of https://github.com/astral-sh/ruff
Allow types.ruff.rs for red-knot playground (#17358)
This commit is contained in:
parent
7d11ef1564
commit
4bfdf54d1a
|
|
@ -31,6 +31,8 @@ const PRODUCTION_HEADERS = {
|
||||||
"Access-Control-Allow-Origin": "https://play.ruff.rs",
|
"Access-Control-Allow-Origin": "https://play.ruff.rs",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ALLOWED_DOMAINS = ["https://playknot.ruff.rs", "https://types.ruff.rs"];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async fetch(
|
async fetch(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -40,8 +42,12 @@ export default {
|
||||||
const { DEV, PLAYGROUND } = env;
|
const { DEV, PLAYGROUND } = env;
|
||||||
|
|
||||||
const headers = DEV ? DEVELOPMENT_HEADERS : PRODUCTION_HEADERS;
|
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) {
|
switch (request.method) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue