@whi/cf-routing - v0.7.0
    Preparing search index...

    Function addCorsHeaders

    • Helper function to add CORS headers to any response

      Preserves any existing CORS headers set by the handler - only adds default CORS headers if they are not already present.

      Parameters

      • response: Response

        The response to add CORS headers to

      • Optionalconfig: CorsConfig<unknown, unknown>

        Optional CORS configuration to use instead of defaults

      • OptionalrequestOrigin: string | null

        The origin from the incoming request

      Returns Response

      A new response with CORS headers added

      const response = new Response('Hello');
      const corsResponse = addCorsHeaders(response);