پیکربندی CORS برای سرور VAST، پیکربندی CORS برای سرور VAST، پیکربندی CORS برای سرور VAST، پیکربندی CORS برای سرور VAST
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
مرورگرهای مدرن محدودیتهای امنیتی یکسانی را برای درخواستهای شبکه جاوا اسکریپت اعمال میکنند، به این معنی که یک برنامه وب که از یک مبدأ اجرا میشود نمیتواند دادههای ارائهشده از منبع دیگری را بازیابی کند. برای VAST، این محدودیت امنیتی از خواندن یک پاسخ تبلیغ VAST که از مبدأ متفاوتی ارائه میشود، مانع از خواندن JavaScript XMLHttpRequests
ساخته شده از کد رندر VAST در جاوا اسکریپت میشود.
این محدودیت امنیتی برای جلوگیری از مشکلاتی است که در آن یک منبع قادر به خواندن دادههایی از مبدا دیگری است که ممکن است کاربر بدون اجازه آن کاربر وارد آن شود. این محدودیت مشکلاتی را برای VAST ارائه شده در محیط جاوا اسکریپت ایجاد می کند زیرا سرور تبلیغات اغلب در دامنه متفاوتی نسبت به پخش کننده تبلیغات قرار دارد.
هدرهای اشتراک منابع متقابل (CORS) یک پیش نویس مشخصات W3C است که به منظور امکان اشتراک گذاری در مبادی مختلف است. برای اینکه در محیط جاوا اسکریپت قابل ارائه باشد، پاسخ سرور تبلیغات 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 در مورد اشتراکگذاری منابع متقاطع مراجعه کنید
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eModern browsers restrict JavaScript from accessing data from different origins (websites) for security reasons, affecting VAST ad serving.\u003c/p\u003e\n"],["\u003cp\u003eThis restriction prevents unauthorized data access between websites, but poses challenges for VAST ads as ad servers and players are often on different domains.\u003c/p\u003e\n"],["\u003cp\u003eCross-Origin Resource Sharing (CORS) headers allow secure data sharing between origins by including specific HTTP headers in the ad server's response.\u003c/p\u003e\n"],["\u003cp\u003eVAST ad servers need to include \u003ccode\u003eAccess-Control-Allow-Origin\u003c/code\u003e and \u003ccode\u003eAccess-Control-Allow-Credentials\u003c/code\u003e headers to enable JavaScript-based ad serving.\u003c/p\u003e\n"]]],["Web browsers restrict JavaScript network requests to the same origin, hindering JavaScript VAST rendering code from accessing VAST ad responses from different origins. To enable cross-origin access, VAST ad servers must include specific CORS headers in their responses. The `Access-Control-Allow-Origin` header should match the request's `Origin`, and `Access-Control-Allow-Credentials: true` allows for proper cookie handling. These headers enable ad players on any origin to read the VAST response, overcoming the same-origin security restriction.\n"],null,["Modern 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)"]]