mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-10 23:58:28 +00:00
* Feat: add documents to the kg * Feat: add versioning to documents * Fix: invalidation of evolved facts * fix: mcp return * fix: invalidAt is not displayed in graph popover * Fix: use document id for the flow * refactor: consolidate document versioning around sessionId instead of documentId * fix: add docs link in welcome email * fix: give more time for larger graphs to settle on * bump: new version 0.1.20 --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
36 lines
874 B
TypeScript
36 lines
874 B
TypeScript
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");
|
|
}
|