Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@tinyhttp/cors
Advanced tools
A rewrite of expressjs/cors module.
HTTP cors header middleware
pnpm i @tinyhttp/cors
import { cors } from '@tinyhttp/cors'
cors(options)
Returns the CORS middleware with the settings specified in the parameters
origin
: Can be a string defining the Access-Control-Allow-Origin
value, a boolean which if set to true sets the header to '*'
or a function which contains the request and response as parameters and must return the value for the Access-Control-Allow-Origin
headermethods
: Array of method names which define the Access-Control-Allow-Methods
header, default to all the most common methods (GET
, HEAD
, PUT
, PATCH
, POST
, DELETE
)allowedHeaders
: Configures the Access-Control-Allow-Headers
CORS header. Expects an array (ex: ['Content-Type'
, 'Authorization'
]).exposedHeaders
: Configures the Access-Control-Expose-Headers
CORS header. If not specified, no custom headers are exposedcredentials
: Configures the Access-Control-Allow-Credentials
CORS header. Set to true to pass the header, otherwise it is omitted.maxAge
: Configures the Access-Control-Max-Age
CORS header. Set to an integer to pass the header, otherwise it is omitted.optionsSuccessStatus
: Provides a status code to use for successful OPTIONS requests, since some legacy browsers (IE11, various SmartTVs) choke on 204.The default configuration is:
{
"origin": "*",
"methods": ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
"optionsSuccessStatus": 204
}
import { App } from '@tinyhttp/app'
import { cors } from '@tinyhttp/cors'
const app = new App()
app.use(cors({ origin: 'https://myfantastic.site/' }))
app.options('*', cors())
app.get('/', (req, res) => {
res.send('The headers contained in my response are defined in the cors middleware')
})
app.listen(3000)
MIT © BRA1L0R
FAQs
CORS middleware for modern Node.js
The npm package @tinyhttp/cors receives a total of 38,624 weekly downloads. As such, @tinyhttp/cors popularity was classified as popular.
We found that @tinyhttp/cors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.