הגדרת CORS לשרתים של VAST
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
דפדפנים מודרניים מחילים הגבלות אבטחה ממקור זהה על רשת JavaScript
כלומר, אפליקציית אינטרנט שפועלת ממקור אחד לא יכולה לאחזר נתונים.
מוצגת ממקור אחר. ב-VAST, הגבלת האבטחה הזו מונעת
JavaScript XMLHttpRequests
נוצר מקוד רינדור JavaScript VAST מקריאה
תגובת 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:
מבטיחה
קובצי ה-Cookie נשלחים ומתקבלים כראוי.
מידע נוסף זמין במפרט הטיוטה של W3C בנושא שיתוף משאבים בין מקורות
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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)"]]