0.1.3 • Published 5 years ago
ecmcors v0.1.3
ecmcors
Easily configure multiple CORS.
Install
npm install ecmcors
# or
yarn add ecmcorsUsage
Set CORS_ALLOW_LIST environment variable.
# If you have multiple origin, you can specify them by separating them with a comma.
CORS_ALLOW_LIST=http://example.com,http://example.net
# If you want to test on a localhost.
CORS_ALLOW_LIST=http://localhost:3000If you do not set the environment variables, all origins are not allowed.
Example(express)
const express = require('express');
const ecmcors = require('ecmcors');
const app = express();
// Only authorized origin will be allowed to pass.
app.get('/', ecmcors, (req, res) => {
res.status(200);
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`listening on ${PORT}`));Development
Test
npm run testCode format
npm run fmt