On this page:
current-cors-origin
current-cors-methods
current-cors-headers
current-cors-max-age
current-cors-credentials-allowed?
wrap-cors

3 CORS🔗

 (require koyo/cors) package: koyo-lib

This module provides a wrapper function and parameters for handling CORS requests.

parameter

(current-cors-origin)  (or/c #f non-empty-string?)

(current-cors-origin origin)  void?
  origin : (or/c #f non-empty-string?)
 = #f

parameter

(current-cors-methods)  (listof non-empty-string?)

(current-cors-methods methods)  void?
  methods : (listof non-empty-string?)
 = '("HEAD" "DELETE" "GET" "PATCH" "POST" "PUT" "OPTIONS")

parameter

(current-cors-headers)  (listof non-empty-string?)

(current-cors-headers headers)  void?
  headers : (listof non-empty-string?)
 = '("*")

parameter

(current-cors-max-age)  exact-nonnegative-integer?

(current-cors-max-age max-age)  void?
  max-age : exact-nonnegative-integer?
 = 86400

parameter

(current-cors-credentials-allowed?)  boolean?

(current-cors-credentials-allowed? allowed?)  void?
  allowed? : boolean?
 = #t
These parameters determine the behavior of wrap-cors. Each one maps to one of the CORS response headers.

When current-cors-origin is #f, the origin is based upon current-application-url-scheme and current-application-url-host.

procedure

(wrap-cors handler)  (-> request? any/c ... response?)

  handler : procedure?
Augments handler to add the various necessary bits of information to support CORS in its response. For OPTIONS requests, wrap-cors takes full control of the request.