問(wèn)題描述
我將這些端點(diǎn)與 JavaScript Ajax 一起使用來(lái)獲取 Instagram 用戶(hù)信息和帖子:
https://www.instagram.com/[用戶(hù)名]/?__a=1
https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={id:[user_id],first:50,after:''}
以前沒(méi)有 CORS 策略錯(cuò)誤,但現(xiàn)在我收到了該錯(cuò)誤(不是每次刷新頁(yè)面時(shí),但幾乎 95% 次):
CORS 政策已阻止從源https://sitename.com"訪(fǎng)問(wèn)https://www.instagram.com/hannahstocking/?__a=1"處的 XMLHttpRequest:無(wú)訪(fǎng)問(wèn)權(quán)限-請(qǐng)求的資源上存在 Control-Allow-Origin 標(biāo)頭.
Instagram 是否已開(kāi)始阻止這些端點(diǎn)或添加了新的速率限制?我該如何解決?
Instagram 引入了 strict-origin-when-cross-origin 政策,只允許以下跨源網(wǎng)站:p>
- https://www.instagram.com
- https://*.fbcdn.net
- https://*.instagram.com
- https://*.cdninstagram.com
- https://*.facebook.com
- https://*.fbsbx.com
這讓我相信他們正在限制網(wǎng)站顯示 API 數(shù)據(jù).數(shù)據(jù)本身仍然可以訪(fǎng)問(wèn),只是不能直接通過(guò)網(wǎng)站訪(fǎng)問(wèn).您需要使用代理或服務(wù)器來(lái)解決它
I am using these endpoints with JavaScript Ajax to get Instagram user information and posts:
https://www.instagram.com/[username]/?__a=1
https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={id:[user_id],first:50,after:''}
There was not a CORS policy error before but now i'm getting that error (not every time when i refresh the page, but almost 95% times):
Access to XMLHttpRequest at 'https://www.instagram.com/hannahstocking/?__a=1' from origin 'https://sitename.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Has Instagram started to block these endpoints or added a new rate limit? How can I fix it?
Instagram has introduced a strict-origin-when-cross-origin policy and is only allowing the following cross origin sites:
- https://www.instagram.com
- https://*.fbcdn.net
- https://*.instagram.com
- https://*.cdninstagram.com
- https://*.facebook.com
- https://*.fbsbx.com
This leads me to believe that they are restricting websites to display the API data. The data itself is still accessible, just not directly over a website. You would need to use a proxy or a server to resolve it
這篇關(guān)于Instagram 公共 API 的新 CORS 政策?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!