Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
node-ajax-seo
Advanced tools
It deals with the most popular crawlers, redirecting them to static directory and serving fresh pages to human users.
Simple node plugin that deals with the most popular crawlers, redirecting them to static directory and serving fresh pages to human users. It doesn't generate your snapshots.
npm install node-ajax-seo --save
var ajaxSeo = require("node-ajax-seo");
app.get("/*", function(req, res,next) {
/**
* It's necessary to define a pattern that matches with not ajax requests:
* In this case all the paths are ajax except:
*
* - /admin and /api paths.
* - resource requests.
* - root
**/
var siteConfig = {
ajaxCondition:{
pattern: /((^\/admin)|(^\/api)|(\.)|(^\/$))/ // you can specify the condition using regex or typical if condition
//toEval: "(req.url.indexOf('.') == -1 && req.url != '/' && req.url.indexOf('/admin') == -1)"
},
indexPath: path.join(__dirname, 'assets', 'index.html'), // your main angular .html by default
staticPages: {
path: path.join(__dirname, 'assets', 'dist', 'static'), // path to your static files
separator: "[---]", // in your static files, the filenames contain some token replacing "/" path.
basePath: {
url: "/",
file: "home.html" // the url basepath is an special case
}
},
debug: false // false by default
};
ajaxSeo.dealWithAjax(siteConfig, req, res, next, function cbk(err) {
if (err) {
console.log(err);
// if we don't have snapshot, we can serve 404 page, log miss request into DB, send a mail... whatevevr,
// but the best option in this case is to generate it and serve it on-the-fly (WIP).
console.log(siteConfig.appPrefix+"We serve the default file caused by the inexistence of the requested one.");
//res.status(err.status).end();
res.sendfile(path.join(siteConfig.staticPages.path,siteConfig.staticPages.basePath.file));
}
else {
console.log(siteConfig.appPrefix+'Sent:', path.join(filePath,fragment));
}
});
});
npm test (not yet)
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
Eric Lara and Santi Pérez, powered by Ondho.
MIT
1.0.1 (2015-01-13)
Add basic debug option.
FAQs
It deals with the most popular crawlers (Google, Twitter, Fb, LinkedIn, ...) redirecting them to static files but serving fresh pages to human users.
The npm package node-ajax-seo receives a total of 1 weekly downloads. As such, node-ajax-seo popularity was classified as not popular.
We found that node-ajax-seo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.