適用於 VAST 的跨源資源共享 (CORS)
新式瀏覽器會對 JavaScript 網路套用相同來源的安全性限制
也就是說,從一個來源執行的網頁應用程式無法擷取資料
其他資源。針對 VAST,這項安全限制可避免
使用 JavaScript VAST 顯示程式碼建立的 JavaScript XMLHttpRequests
,也就是讀取
另一個來源提供的 VAST 廣告回應。
這項安全性限制旨在防止以下問題發生:單一來源能
來從使用者可能登入的另一個來源讀取資料
授予使用者的權限這項限制為 JavaScript 放送的 VAST 帶來問題
因為廣告伺服器通常位於
廣告播放器。
跨來源資源分享 (CORS) 標頭是一種 W3C 草擬規格,
這樣就能在不同來源之間分享檔案可在 JavaScript 中提供
VAST 廣告伺服器回應必須包含下列 HTTP CORS 標頭:
Access-Control-Allow-Origin: <origin header value>
Access-Control-Allow-Credentials: true
敬上
這個 HTTP 標頭允許任何來源上的廣告播放器讀取 VAST 回應
來自廣告伺服器來源的請求。
Access-Control-Allow-Origin:
的值
必須是與廣告請求一併傳送的
Origin
標頭值。
Access-Control-Allow-Credentials:
標頭可確保
正確傳送及接收 Cookie。
詳情請參閱跨來源資源分享的 W3C 草擬規格。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-03-07 (世界標準時間)。
[null,null,["上次更新時間:2025-03-07 (世界標準時間)。"],[[["Modern browsers restrict JavaScript from accessing data from different origins for security reasons, impacting VAST ad serving."],["This restriction prevents JavaScript in VAST ads from loading resources like the ad response if they are hosted on a different domain than the player."],["Cross-Origin Resource Sharing (CORS) headers enable cross-origin data access, requiring VAST ad servers to include specific headers to allow JavaScript ad players to read responses."],["These CORS headers, `Access-Control-Allow-Origin` and `Access-Control-Allow-Credentials`, specify permitted origins and ensure proper cookie handling for seamless ad delivery."]]],[]]