Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 2, 2024 via pnpm

cors 2.8.5

Node.js CORS middleware
Package summary
Share
0
issues
1
license
3
MIT
Package created
31 Jan 2013
Version published
4 Nov 2018
Maintainers
2
Total deps
3
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
cors@2.8.5
object-assign@4.1.1
vary@1.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of cors 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
object-assign4.1.12.61 kBMIT
prod
vary1.1.23.68 kBMIT
prod

Visualizations

Frequently Asked Questions

What does cors do?

The CORS package in Node.js is used as middleware for Connect/Express to enable Cross-Origin Resource Sharing (CORS). With the help of CORS, resources from various origins are made available to the browsers. Various options can be implemented for CORS as per requirements.

How do you use cors?

To use the CORS package, you can begin by installing it using the npm install command npm install cors. You can then import it into your code with var cors = require('cors'). You can enable CORS for all requests by adding app.use(cors()) or for a specific route, using app.get('/your-route', cors(), yourHandlerFunction). Further customizations and configurations pertaining to CORS such as setting origins, handling preflight requests, and configuring dynamic CORS are also possible. Here is an example of enabling CORS for all requests:

var express = require('express');
var cors = require('cors');
var app = express();
app.use(cors());
app.get('/products/:id', function (req, res, next) {
  res.json({msg: 'This is CORS-enabled for all origins!'});
});
app.listen(80, function () {
  console.log('CORS-enabled web server listening on port 80');
});

Where are the cors docs?

The documentation for CORS can be found in the repository available at https://github.com/expressjs/cors. The readme file provides details about installation, usage, and configuration options. For a deep dive into the effects of various CORS headers, the article at http://www.html5rocks.com/en/tutorials/cors/ can be referred to.