CORSPlugin adds CORS headers to your oRPC responses, allowing browsers to make cross-origin requests.
Usage
Default behavior
Without any options, the plugin echoes back the request’sOrigin header as Access-Control-Allow-Origin and allows GET, HEAD, PUT, POST, DELETE, PATCH methods.
Options
Allowed origins. Can be a string, an array of strings,
'*' for wildcard, null to disallow all, or an async function that receives the request origin and returns the allowed value.Default: echoes back the request origin.HTTP methods to allow in the
Access-Control-Allow-Methods header.Default: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']HTTP headers to allow. If not set, echoes back
Access-Control-Request-Headers from the preflight request.HTTP headers to expose via
Access-Control-Expose-Headers.Number of seconds the preflight response can be cached (
Access-Control-Max-Age).Set
Access-Control-Allow-Credentials: true. Required when the client sends cookies or authorization headers with credentials: 'include'.Sets the
Timing-Allow-Origin header, using the same format as origin.