VAST サーバーの CORS を構成する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
最新のブラウザでは、JavaScript ネットワークに同一オリジンのセキュリティ制限が適用されます
つまり、ある送信元から実行されているウェブ アプリケーションは、
配信する場合です。VAST の場合、このセキュリティ制限により
読み取りからの JavaScript VAST レンダリング コードから作成された JavaScript XMLHttpRequests
他の配信元から配信された VAST 広告レスポンス。
このセキュリティ制限は、ユーザーがログインしている可能性のある別のオリジンから、ユーザーの許可なく 1 つのオリジンがデータを読み取れる問題を防ぐことを目的としています。広告サーバーは広告プレーヤーとは異なるドメインにあることが多いため、この制限は JavaScript 環境で配信される VAST に問題を引き起こします。ただし、クロスオリジン リソース シェアリング(CORS)ヘッダーは、異なるオリジン間での共有を許可することで、この制限を回避する W3C 勧告です。
CORS ヘッダー
クロスオリジンの問題を回避するには、SDK によって行われたリクエストに対する VAST 広告サーバーのレスポンスに、次の HTTP CORS ヘッダーを含める必要があります。
Access-Control-Allow-Origin: <origin header value>
Access-Control-Allow-Credentials: true
これらのヘッダーを使用すると、任意の送信元の広告プレーヤーが VAST レスポンスを読み取ることができます。
指定することもできますAccess-Control-Allow-Origin
の値を広告リクエストとともに送信される Origin
ヘッダーの値に設定し、Access-Control-Allow-Credentials
を true
に設定して、Cookie が正しく送受信されるようにします。
CORS を有効にする詳しい手順については、以下をご覧ください。
クロスオリジン リソース シェアリングを有効にする。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-31 UTC。
[null,null,["最終更新日 2025-08-31 UTC。"],[[["\u003cp\u003eModern browsers restrict JavaScript from accessing data from different origins for security reasons, impacting VAST ads served from a separate domain than the player.\u003c/p\u003e\n"],["\u003cp\u003eCross-Origin Resource Sharing (CORS) headers enable cross-origin data sharing, allowing VAST ads to be served from a different domain than the player.\u003c/p\u003e\n"],["\u003cp\u003eVAST ad server responses should include specific CORS headers: \u003ccode\u003eAccess-Control-Allow-Origin\u003c/code\u003e (set to the request's \u003ccode\u003eOrigin\u003c/code\u003e header value) and \u003ccode\u003eAccess-Control-Allow-Credentials\u003c/code\u003e (set to \u003ccode\u003etrue\u003c/code\u003e).\u003c/p\u003e\n"]]],[],null,["# Configure CORS for VAST servers\n\nModern browsers apply same-origin security restrictions to JavaScript network\nrequests, meaning that a web application running from one origin cannot retrieve data\nserved from a different origin. For VAST, this security restriction prevents\nJavaScript XMLHttpRequests made from JavaScript VAST rendering code from reading\na VAST ad response served from a different origin.\n\nThis security restriction is meant to prevent issues where one origin is able\nto read data from another origin that a user may be logged in to without that\nuser's permission. The restriction poses problems for VAST served in a JavaScript\nenvironment because an ad server is often on a different domain than the\nads player. However, [Cross-Origin Resource Sharing (CORS)](//www.w3.org/TR/cors)\nheaders is a W3C recommendation that works around this restriction by allowing\nsharing across different origins.\n\nCORS headers\n------------\n\nTo avoid cross-origin problems, VAST ad server responses to requests made by the SDK must\ninclude following HTTP CORS headers: \n\n```text\nAccess-Control-Allow-Origin: \u003corigin header value\u003e\nAccess-Control-Allow-Credentials: true\n```\n\nThese headers allow an ads player on any origin to read the VAST response\nfrom the ad server origin. Set the value of `Access-Control-Allow-Origin`\nto the value of the `Origin` header sent with the ad request, and\n`Access-Control-Allow-Credentials` to `true` to ensure\nthat cookies are sent and received properly.\n\nFor further instructions on enabling CORS, see\n[Enable cross-origin resource sharing](//enable-cors.org/)."]]