Caching effect on CORS: No 'Access-Control-Allow-Origin' header is present on the requested resource

后端 未结 6 1296
故里飘歌
故里飘歌 2020-12-02 09:05

The short version of this issue is we are seeing the typical CORS error (x has been blocked by CORS policy: No \'Access-Control-Allow-Origin\' header is present on the

6条回答
  •  长情又很酷
    2020-12-02 09:56

    Assuming that the CROS configuration has been set in the S3 already, these two points below can make sure that the video will be always loaded on the browser.

    1. Add crossorigin=”anonymous” on the tag
    2. Add the "?q=#{Time.now.to_i}" at the end of the S3 URLs

    HAML + Ruby code will look something like this.

        %video{controls: "", controlslist: "nodownload", crossorigin: 'anonymous'}
         %source{src: "#{s3_url}?q=#{Time.now.to_i}", type: "video/mp4"}
    

提交回复
热议问题