Spaces:
Runtime error
Runtime error
Download apps/webapp/app/utils/apiCors.ts from BTankut/Context-Store-LLM: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/spaces/BTankut/Context-Store-LLM/resolve/main/apps/webapp/app/utils/apiCors.ts
- Command line
-
hf download hf://spaces/BTankut/Context-Store-LLM/apps/webapp/app/utils/apiCors.ts
-
curl -L -o apiCors.ts https://huggingface.co/spaces/BTankut/Context-Store-LLM/resolve/main/apps/webapp/app/utils/apiCors.ts
867 Bytes
| import { cors } from "remix-utils/cors"; | |
| type CorsMethod = "GET" | "HEAD" | "PUT" | "PATCH" | "POST" | "DELETE"; | |
| type CorsOptions = { | |
| methods?: CorsMethod[]; | |
| /** Defaults to 5 mins */ | |
| maxAge?: number; | |
| origin?: boolean | string; | |
| credentials?: boolean; | |
| exposedHeaders?: string[]; | |
| }; | |
| export async function apiCors( | |
| request: Request, | |
| response: Response, | |
| options: CorsOptions = { maxAge: 5 * 60 }, | |
| ): Promise<Response> { | |
| if (hasCorsHeaders(response)) { | |
| return response; | |
| } | |
| return cors(request, response, options); | |
| } | |
| export function makeApiCors( | |
| request: Request, | |
| options: CorsOptions = { maxAge: 5 * 60 }, | |
| ): (response: Response) => Promise<Response> { | |
| return (response: Response) => apiCors(request, response, options); | |
| } | |
| function hasCorsHeaders(response: Response) { | |
| return response.headers.has("access-control-allow-origin"); | |
| } | |