simple CORS
Summary
Simple CORS method to control response headers.
Install
npm install -P corsable
Usage
const corsable = ;const micro = ; // or your chosen framework const simple_handler = { ; micro;}; const configured_handler = { ; micro;}; const origin_list_handler = { ; micro;}; const origin_regex_handler = { ; micro;};
Or, you can create some middleware (micro-compatible example, but should work for others as well):
const corsable = ;const middleware = { ; return ;}; const cors = ; moduleexports = ;
Options
max_age
(Access-Control-Max-Age) [integer]
default: 86400
origin
(Access-Control-Allow-Origin) [string, array, regexp]
default: *
allow_methods
(Access-Control-Allow-Methods) [array]
default: [ 'POST', 'GET', 'PUT', 'PATCH', 'DELETE', 'OPTIONS' ]
allow_headers
(Access-Control-Allow-Headers) [array]
default: [ 'X-Requested-With', 'Access-Control-Allow-Origin', 'X-HTTP-Method-Override', 'Content-Type', 'Authorization', 'Accept', 'Cookie' ]
expose_headers
(Access-Control-Expose-Headers) [array]
default: [ 'Authorization', 'Set-Cookie' ]