@shise/cors
v0.0.3
Published
Shise CORS
Downloads
3
Maintainers
Readme
CORS Middleware
A middleware for handling Cross-Origin Resource Sharing (CORS) in your web server.
Installation
npm install @shise/cors
Usage
const cors, { CorsOptions } = require('@shise/cors')
const { Controller } = require('shise')
const controller = new Controller()
controller.use(cors(/* optional CorsOptions */))
Options
allowedOrigins (optional)
: Array of allowed origins. Default is an empty array.
allowedMethods (optional)
: Array of allowed HTTP methods. Default is ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'].
allowedHeaders (optional)
: Array of allowed headers. Default is an empty array.
exposedHeaders (optional)
: Array of headers exposed to the client. Default is an empty array.
maxAge (optional)
: The maximum time (in seconds) that a preflight request may be cached. Default is 600.
credentials (optional)
: Boolean indicating whether credentials (e.g., cookies) should be included. Default is false.