กำหนดค่า CORS สำหรับเซิร์ฟเวอร์ VAST
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เบราว์เซอร์สมัยใหม่ใช้ข้อจำกัดด้านความปลอดภัยต้นทางเดียวกันกับเครือข่าย JavaScript
ซึ่งหมายความว่าเว็บแอปพลิเคชันที่ทำงานจากต้นทางหนึ่งจะเรียกข้อมูลไม่ได้
มาจากต้นทางที่อื่น สำหรับ VAST ข้อจำกัดด้านความปลอดภัยนี้จะป้องกัน
JavaScript XMLHttpRequests
สร้างจากโค้ดการแสดงผล VAST แบบ JavaScript จากการอ่าน
การตอบกลับโฆษณา VAST ที่แสดงจากต้นทางอื่น
ข้อจำกัดด้านความปลอดภัยนี้มีไว้เพื่อป้องกันปัญหาที่ต้นทางหนึ่งๆ ทำได้
เพื่ออ่านข้อมูลจากต้นทางอื่นที่ผู้ใช้อาจเข้าสู่ระบบโดยไม่ได้เข้าสู่ระบบ
สิทธิ์ของผู้ใช้ การจำกัดนี้ทำให้เกิดปัญหาสำหรับ VAST ที่แสดงใน JavaScript
เนื่องจากเซิร์ฟเวอร์โฆษณามักจะอยู่บนโดเมนที่แตกต่างจาก
โปรแกรมเล่นโฆษณา
ส่วนหัวกลไกการแชร์ทรัพยากรข้ามโดเมน (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:
จะช่วยให้แน่ใจว่า
มีการส่งและรับคุกกี้อย่างเหมาะสม
โปรดดูข้อมูลเพิ่มเติมที่ข้อกำหนดเฉพาะฉบับร่างของ W3C เกี่ยวกับการแชร์ทรัพยากรข้ามโดเมน
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 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 ad serving.\u003c/p\u003e\n"],["\u003cp\u003eThis restriction prevents JavaScript in VAST ads from loading resources like the ad response if they are hosted on a different domain than the player.\u003c/p\u003e\n"],["\u003cp\u003eCross-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.\u003c/p\u003e\n"],["\u003cp\u003eThese CORS headers, \u003ccode\u003eAccess-Control-Allow-Origin\u003c/code\u003e and \u003ccode\u003eAccess-Control-Allow-Credentials\u003c/code\u003e, specify permitted origins and ensure proper cookie handling for seamless ad delivery.\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\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 into 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.\n\n\nCross-Origin Resource Sharing (CORS) headers is a W3C draft specification meant\nto allow sharing across different origins. To be servable in a JavaScript\nenvironment a VAST ad server's response must include the following HTTP CORS headers: \n\n```text\nAccess-Control-Allow-Origin: \u003corigin header value\u003e\nAccess-Control-Allow-Credentials: true\n```\nThis HTTP header allows an ads player on any origin to read the VAST response from the ad server origin. The value of `Access-Control-Allow-Origin:` should be the value of the `Origin` header sent with the ad request. The `Access-Control-Allow-Credentials:` header ensures that cookies are sent and received properly.\n\n\u003cbr /\u003e\n\n\nFor more information, refer to the [W3C Draft Specification on Cross-Origin Resource Sharing](//www.w3.org/TR/cors)"]]