access-control-allow-origin

Posted lavin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了access-control-allow-origin相关的知识,希望对你有一定的参考价值。

when use  vastinspector to check our  vast response ,it  tiped :

"no ‘access-control-allow-origin‘ header is present on the requested resource. origin ‘https://imasdk.googleapis.com‘  is therefore not allow access " on the console ,

so we had to solve it ,to make sure our video play  smoothly 。

according the docs :

Access-Control-Allow-Origin: <origin header value>     
Access-Control-Allow-Credentials: true

we add headers before response:
origin := r.Header.Get("Origin")
w.Header().Set("Access-Control-Allow-Origin", origin)
w.Header().Set("Access-Control-Allow-Credentials", "true")

then our vast can play .

 

andskipable vast like this:


<VAST version="2.0">
    <Ad id="159033832">
        <InLine>
            <AdSystem>doubleclick</AdSystem>
            <Impression><![CDATA[
https://test.adomain.com/impression?k=598cf38025536d7377e2bcbb&p=NjAyOHwyODAwMHwwfDIyfDE1OTAzMzgzMnw3MDQzMDUwNzN8bm9ybWFsfGRvdWJsZWNsaWNrfDEyMDB4NjI3fDh8YW5kcm9pZHw2LjAuMHx8c20tZzYxMG18fHxVU3x8fHxub3JtYWx8fGNvbS5wb3dlcmQuY2xlYW5lcnx8fHx8fHx8NTk4Y2YzODAyNTUzNmQ3Mzc3ZTJiY2JifDUyLjIzLjExMi4wfHx8fHx8MHwwfDE4OWMzYTQ3LTViMWMtNDIwZi1hNzZlLTgxZWNhMDI1YTMxZHx8fHNhbXN1bmd8fHxyYW5rX2NwbV9jYW1wfHwzfHx8LHRiLGRiLHJlfHsiY2FycmllciI6IjcwMTE5IiwiY2l0eSI6ImFzaGJ1cm4iLCJjdHIiOiIwLjA1IiwiY3R5cGUiOiJjcG0iLCJwYXJzZSI6IjEiLCJyYW5rIjoiMCIsInJlcXR5cGUiOiJ2bmEiLCJzZWFyY2giOiIxIiwidHJhZmZpY190eXBlIjoiYXBwIn18MTUwMjQwOTYwMHx8MXwxMTkxNXx8fHx8fGh0dHBzOi8vcGxheS5nb29nbGUuY29t
]]></Impression>
            <Creatives>
                <Creative id="704305157">
                    <Linear skipoffset="00:00:05">
                        <Duration>00:00:23</Duration>
                        <TrackingEvents>
                            <Tracking event="start"><![CDATA[
https://analytics-test.adomain.com/collect?app_id=com.powerd.cleaner&advertiser_id=22&campaign_id
]]></Tracking>
                            <Tracking event="midpoint"><![CDATA[
https://analytics-test.adomain.com/collect?app_id=com.powerd.cleaner&advertiser_id=22&campaign_id=
                            <Tracking event="complete"><![CDATA[
https://analytics-test.adomain.com/collect?app_id=com.powerd.cleaner&advertiser_id=22&campaign_id=
                        <VideoClicks>
                            <ClickThrough><![CDATA[
https://test.adomain.com/click?k=598cf38025536d7377e2bcbb&p=
]]></ClickThrough>
                            <ClickTracking />
                        </VideoClicks>
                        <MediaFiles>
                            <MediaFile id="1" delivery="progressive" type="video/mp4" bitrate="600" width="1280" height="720"><![CDATA[
https://d3e8xvf8dyclkj.cloudfront.net/cdn-adn/17/08/04/13/42/5984094d8709d.mp4
]]></MediaFile>
                        </MediaFiles>
                    </Linear>
                </Creative>
            </Creatives>
            <Extensions>
                <Extension>
                    <CustomTracking>
                        <Tracking event="skip"><![CDATA[
https://test.xxx.com/impression?k=11&p=200
]]></Tracking>
                    </CustomTracking>
                </Extension>
            </Extensions>
        </InLine>
    </Ad>
</VAST>

 

 
 

 








以上是关于access-control-allow-origin的主要内容,如果未能解决你的问题,请参考以下文章

PHP没有按顺序执行

跨域请求被阻止 Symfony/AngularJS

C# MVC js 跨域

PHP Ajax 跨域问题最佳解决方案

PHP Ajax 跨域问题最佳解决方案

PHP Ajax 跨域问题最佳解决方案