cors 0.3.0
Install from the command line:
Learn more about npm packages
$ npm install @curveball/cors@0.3.0
Install via package.json:
"@curveball/cors": "0.3.0"
About this version
This package is a middleware for the Curveball framework.
npm install @curveball/cors
After installing the NPM package, simply import the CORS middleware to an existing Curveball server:
import cors from '@curveball/cors';
import { Application } from '@curveball/core';
const app = new Application();
app.use(cors());
When manually providing CORS options, this is how it should look:
app.use(cors({
allowOrigin: '*',
allowHeaders: ['Content-Type', 'Accept'],
allowMethods: ['GET', 'POST'],
exposeHeaders: ['Link', 'Date'],
credentials: true
}));
If no options are given, it will use these defaults:
{
allowOrigin: '*',
allowHeaders: ['Content-Type', 'User-Agent', 'Authorization', 'Accept', 'Prefer', 'Prefer-Push', 'Link'],
allowMethods: ['DELETE', 'GET', 'PATCH', 'POST', 'PUT'],
exposeHeaders: ['Location', 'Link'],
credentials: false
}