
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@schibsted/middy-cors
Advanced tools
Middy middleware for adding CORS headers to success response and errors
This middleware sets HTTP CORS headers, necessary for making cross-origin requests, to the response object.
Sets headers in after and onError phases.
This is an alternative to standard Middy cors handler with the following differences:
To install this middleware you can use NPM:
npm install --save @schibsted/middy-cors
allowedOrigins (array) - list of allowed origins or ['*'] for allowing all originsexposeHeaders (array) - list of headers to exposemaxAge (string) - value passed to access-control-max-age headercredentials (bool) - value passed to access-control-allow-credentials headerallowMethods (array) - list of allowed HTTP methodsallowHeaders (array) - list of allowed HTTP headersconst middy = require('@middy/core');
const cors = require('@schibsted/middy-cors');
const handler = middy(async () => ({
statusCode: 200,
body: JSON.stringify({ foo: 'bar' }),
}));
handler
.use(cors({ allowedOrigins: ['https://www.vg.no', 'https://www.tek.no']}));
// when Lambda runs the handler...
handler({}, {}, (_, response) => {
expect(response).toEqual({
statusCode: 200,
headers: {
'access-control-allow-origin': 'https://www.vg.no',
},
body: JSON.stringify({ foo: 'bar' }),
})
})
Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.
3.0.1 (2022-08-29)
FAQs
Middy middleware for adding CORS headers to success response and errors
The npm package @schibsted/middy-cors receives a total of 15 weekly downloads. As such, @schibsted/middy-cors popularity was classified as not popular.
We found that @schibsted/middy-cors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.