MCPcopy Index your code
hub / github.com/simstudioai/sim / applyCorsHeaders

Function applyCorsHeaders

apps/sim/proxy.ts:102–110  ·  view source on GitHub ↗
(response: NextResponse, policy: CorsPolicy)

Source from the content-addressed store, hash-verified

100const CORS_PREFLIGHT_MAX_AGE = '86400'
101
102function applyCorsHeaders(response: NextResponse, policy: CorsPolicy): void {
103 response.headers.set('Access-Control-Allow-Origin', policy.origin)
104 response.headers.set('Access-Control-Allow-Credentials', String(policy.credentials))
105 response.headers.set('Access-Control-Allow-Methods', policy.methods)
106 response.headers.set('Access-Control-Allow-Headers', policy.headers)
107 if (policy.origin !== '*') {
108 response.headers.set('Vary', 'Origin')
109 }
110}
111
112/** Next's auto-OPTIONS doesn't carry middleware headers, so we answer preflight here. */
113function buildPreflightResponse(policy: CorsPolicy): NextResponse {

Callers 2

buildPreflightResponseFunction · 0.85
proxyFunction · 0.85

Calls 1

setMethod · 0.65

Tested by

no test coverage detected