You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

静态网站调用Instagram Stories API遇net::ERR_BLOCKED_BY_RESPONSE.NotSameOrigin错误求助

Fixing net::ERR_BLOCKED_BY_RESPONSE.NotSameOrigin for Instagram Media on Static JS/jQuery Sites

Hey there, let’s break down why this is happening and walk through solutions that work for static sites (no PHP required):

Why This Error Happens

Instagram’s CDN enforces strict cross-origin resource sharing (CORS) and referrer policies. When you try to embed their media directly in a <video> (or even <img>) tag on your own domain, your browser blocks the request to protect against unauthorized resource usage—this is the browser’s Same-Origin Policy at work.

Also, quick note: The URL you’re using ends with .jpg (it’s an image), but you’re embedding it in a <video> tag. That mismatch might be exacerbating the issue, so let’s address that too.

Solutions for Static JS/jQuery Sites

1. Correct the Tag Type First

If the API returned an image URL (like your .jpg example), swap the <video> tag for an <img> tag. Browsers handle image cross-origin rules slightly differently, and this might resolve the issue immediately:

<img width="342" height="608" src="https://scontent-jnb1-1.cdninstagram.com/v/t51.2885-15/e15/242204298_1728375270686500_5634415857798350440_n.jpg?_nc_ht=scontent-jnb1-1.cdninstagram.com&_nc_cat=104&_nc_ohc=3O8LpuGJsdUAX_E1Dxz&edm=AHlfZHwBAAAA&ccb=7-4&oh=0a22779e81f47ddb84155f98f6f5f75f&oe=6148F26D&_nc_sid=21929d" alt="Instagram media">

2. Use a CORS Proxy (No Backend Required)

If you need to keep using a <video> tag (or the image still blocks), a CORS proxy acts as a middleman to forward the request and add the necessary CORS headers. You can either use a public proxy or deploy your own lightweight one:

Option A: Public CORS Proxy (Quick Test)

Prefix your media URL with a public proxy like https://cors-anywhere.herokuapp.com/ (note: you may need to visit the proxy URL first to request temporary access):

<video width="342" height="608" src="https://cors-anywhere.herokuapp.com/https://scontent-jnb1-1.cdninstagram.com/v/t51.2885-15/e15/242204298_1728375270686500_5634415857798350440_n.jpg?_nc_ht=scontent-jnb1-1.cdninstagram.com&_nc_cat=104&_nc_ohc=3O8LpuGJsdUAX_E1Dxz&edm=AHlfZHwBAAAA&ccb=7-4&oh=0a22779e81f47ddb84155f98f6f5f75f&oe=6148F26D&_nc_sid=21929d"></video>

Option B: Deploy Your Own Proxy (Stable & Private)

For long-term use, deploy a simple serverless function with Vercel or Netlify. Here’s a Vercel example:

  1. Create a file api/cors.js in your project:
export default async function handler(req, res) {
  const targetUrl = req.query.url;
  if (!targetUrl) return res.status(400).send("Missing 'url' parameter");

  // Allow cross-origin requests from your domain (replace with your site URL)
  res.setHeader("Access-Control-Allow-Origin", "https://your-static-site.com");
  res.setHeader("Access-Control-Allow-Methods", "GET");

  try {
    const response = await fetch(targetUrl);
    // Copy all headers from the original response
    for (const [key, value] of response.headers.entries()) {
      res.setHeader(key, value);
    }
    // Stream the response body to the client
    res.send(await response.arrayBuffer());
  } catch (err) {
    res.status(500).send(`Proxy error: ${err.message}`);
  }
}
  1. Deploy your site to Vercel, then use the proxy in your tag:
<video width="342" height="608" src="https://your-vercel-domain.vercel.app/api/cors?url=https://scontent-jnb1-1.cdninstagram.com/v/t51.2885-15/e15/242204298_1728375270686500_5634415857798350440_n.jpg?_nc_ht=scontent-jnb1-1.cdninstagram.com&_nc_cat=104&_nc_ohc=3O8LpuGJsdUAX_E1Dxz&edm=AHlfZHwBAAAA&ccb=7-4&oh=0a22779e81f47ddb84155f98f6f5f75f&oe=6148F26D&_nc_sid=21929d"></video>

3. Try an Iframe (Last Resort)

Some CDNs allow embedding media via iframes. Test this:

<iframe width="342" height="608" src="https://scontent-jnb1-1.cdninstagram.com/v/t51.2885-15/e15/242204298_1728375270686500_5634415857798350440_n.jpg?_nc_ht=scontent-jnb1-1.cdninstagram.com&_nc_cat=104&_nc_ohc=3O8LpuGJsdUAX_E1Dxz&edm=AHlfZHwBAAAA&ccb=7-4&oh=0a22779e81f47ddb84155f98f6f5f75f&oe=6148F26D&_nc_sid=21929d" frameborder="0" allowfullscreen></iframe>

Final Notes

  • Always double-check that the media URL matches the tag type (video URLs should end with .mp4 or similar, images with .jpg/.png).
  • Public proxies can be unreliable or have rate limits, so deploying your own is the best long-term fix.

内容的提问来源于stack exchange,提问作者Random Kindle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 12:52:26