
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
connect-block-hotlinks
Advanced tools
I wrote this middleware to keep people from embedding my site's images into their own sites.
It compares the HTTP headers Host
and Referer
to make sure they are from the same 2nd-level domain.
For example, if Host is img.example.com
then referer can be http://example.com/
or http://blog.example.com/
but not http://another.com/
.
This will not stop a determined attacker! For that you should use CORS and authentication mechanisms. But it will
prevent people stealing your bandwidth by using a URL to your image in the 'src' of an tag on another site.
It follows a classic Connect/Express middleware pattern:
var express = require('express');
var blockHotlinks = require('connect-block-hotlinks');
var app = express();
app.use "/img/*", blockHotlinks
Depending on the request, the middleware will either:
FAQs
Middleware for blocking cross-origin requests (hotlinks)
The npm package connect-block-hotlinks receives a total of 4 weekly downloads. As such, connect-block-hotlinks popularity was classified as not popular.
We found that connect-block-hotlinks 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.