
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ekit-cross-site
Advanced tools
You may face the problem with Access-Control-Allow-Origin when you want to call API on cross domain. Here is the simple solution for that.
Require ekit-cross-site module before all other API defination and put the list of allow site as below
Note: only use with expressjs
...
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
...
});
require('ekit-cross-site')(app, ['http://127.0.0.1:9000', 'http://0.0.0.0:9000']);
...
var config = {
allow: ['http://127.0.0.1:9000', 'http://0.0.0.0:9000']
};
module.exports = function(app, allowList) {
// allow
config.allow = allowList;
// allow request
app.all('/*', function(req, res, next) {
var isPass = false;
for (var i in config.allow) {
if (req.headers.origin === config.allow[i]) {
isPass = true;
}
};
if (isPass === true) {
res.header('Access-Control-Allow-Origin', req.headers.origin);
res.header('Access-Control-Allow-Methods', '*');
res.header('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept');
};
return next();
});
}
FAQs
ekit package, support cross site manager
We found that ekit-cross-site demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.