1
2
3
4
5
6
7
8
9
10
11
12
13
const DEFAULT_CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
} as const;
export default function setCorsHeaders(
response: Response,
headers: Partial<typeof DEFAULT_CORS_HEADERS> = DEFAULT_CORS_HEADERS,
): Response {
response.headers.set("Access-Control-Allow-Origin", headers["Access-Control-Allow-Origin"]);
response.headers.set("Access-Control-Allow-Methods", headers["Access-Control-Allow-Methods"]);
return response;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.