When you point your browser directly at an image URL that lives on another domain, you’re often running straight into one of two defenses the “image host” has put in place:
Hot-link protection (referrer checks)
CORS or framing restrictions (Access-Control-Allow-Origin, X-Frame-Options, etc.)
Google Image Search “just works” because it never serves you the image from the original host’s domain. Instead it:
Crawls (or proxies) the original image onto a Google-controlled domain (e.g. https://encrypted-tbn0.gstatic.com/…)
Serves it with permissive headers (no hot-link checks, broad CORS, no SAMEORIGIN frame‐busting)
Displays or frames that Google‐hosted copy in your browser
Your site, by contrast, is hitting the origin server directly, and that server has decided:
• “I only let my images show up on my own domain(s)”
• “If the Referer isn’t me, drop the request”
• or “No cross-origin fetches unless you send me Access-Control-Allow‐Origin:*”
How to confirm
Open DevTools → Network
Reload your page where the image is embedded
Look at the image request’s response headers
Is there an Access-Control-Allow-Origin header?
Is there an X-Frame-Options: SAMEORIGIN header?
Does the response come back 403 Forbidden or a tiny “blocked” graphic?
You’ll likely see something like:
code
HTTP/1.1 403 Forbidden
X-Frame-Options: SAMEORIGIN
Referrer-Policy: no-referrer
…or no CORS header at all…
Work-arounds
Host (or proxy) the image yourself
• Spin up a tiny proxy on your server (or a serverless function) that fetches the image for you, then serves it with permissive CORS
Ask the origin site to enable CORS for your domain
• They’d need to add
Access-Control-Allow-Origin: https://your-site.com
to their image response
Use a third-party image-proxy service
• E.g. Imgix, Cloudinary, Fastly Image Optimizer, or any “fetch-and-cache” CDN
If it’s a frame/iframe scenario, double-check that they’re not sending
X-Frame-Options: SAMEORIGIN
Example: simple Node.js proxy
js
// install express & node-fetch
const express = require('express');
const fetch = require('node-fetch');
const app = express();
app.get('/image-proxy', async (req, res) => {
const url = req.query.url; // e.g. https://example.com/pic.jpg
const resp = await fetch(url);
resp.headers.forEach((v,k) => res.setHeader(k, v));
// override CORS so browsers let you use it:
res.setHeader('Access-Control-Allow-Origin', '*');
resp.body.pipe(res);
});
app.listen(3000, ()=> console.log('proxy up at http://localhost:3000'));