Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@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.
FAQs
Middy middleware for adding CORS headers to success response and errors
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.