Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@middy/cors
Advanced tools
CORS (Cross-Origin Resource Sharing) middleware for the middy framework
WARNING: this package has been deprecated. Please use the renamed version
@middy/http-cors
!
CORS middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda
This middleware sets CORS headers (Access-Control-Allow-Origin
, Access-Control-Allow-Headers
, Access-Control-Allow-Credentials
), necessary for making cross-origin requests, to the response object.
Sets headers in after
and onError
phases.
To install this middleware you can use NPM:
npm install --save @middy/cors
origin
(string) (optional): origin to put in the header (default: "*
")headers
(string) (optional): value to put in Access-Control-Allow-Headers (default: null
)credentials
(bool) (optional): if true, sets the Access-Control-Allow-Origin
as request header Origin
, if present (default false
)const middy = require('middy')
const { cors } = require('middy/middlewares')
const handler = middy((event, context, cb) => {
cb(null, {})
})
handler.use(cors())
// when Lambda runs the handler...
handler({}, {}, (_, response) => {
expect(response.headers['Access-Control-Allow-Origin']).toEqual('*')
})
For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.
Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.
Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.
FAQs
CORS (Cross-Origin Resource Sharing) middleware for the middy framework
The npm package @middy/cors receives a total of 25 weekly downloads. As such, @middy/cors popularity was classified as not popular.
We found that @middy/cors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.