3

我刚刚将我的博客从 wordpress 更改为 django-zinnia。Zinnia 在 django-admin 中使用 WYMeditor ( https://github.com/wymeditor/wymeditor ) iframe 来输入博客文章文本和内容,现在由于同源问题,我无法访问 iframe。我在浏览器控制台中看到的错误是:

Blocked a frame with origin "http://www.mydomain.com" from accessing a frame with origin "http://mybucket.s3.amazonaws.com". 
Protocols, domains, and ports must match.
WYMeditor.WymClassSafari.initIframe 
onload

我可以在存储桶的 CORS 配置中更新一个参数以允许 iframe 加载跨域吗?我已经有了

 <AllowedOrigin>http://www.mydomain.com</AllowedOrigin> 

在我目前的 CORS 规则中:

<?xml version="1.0" encoding="UTF-8"?>
    <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
         <CORSRule>
             <AllowedOrigin>http://mydomain.herokuapp.com</AllowedOrigin>
             <AllowedOrigin>http://mydomain.com</AllowedOrigin>
             <AllowedOrigin>http://www.mydomain.com</AllowedOrigin>
             <AllowedMethod>GET</AllowedMethod>
             <MaxAgeSeconds>3000</MaxAgeSeconds>
             <AllowedHeader>Content-*</AllowedHeader>
             <AllowedHeader>Host</AllowedHeader>
             <AllowedHeader>Authorization</AllowedHeader>
        </CORSRule>
   </CORSConfiguration>
4

1 回答 1

5

CORS 标头不会影响 Safari 中 iframe 的同源策略。

您可以使用框架在框架之间进行通信,postMessage也可以将子域附加mydomain.com到您的 S3 存储桶并通过设置放宽同源策略document.domain(此方法仅适用于同一域的子域之间通信,它不适用于不同域之间) .

您可以从 StackOverflow 上的这个答案中了解有关 iframe 通信的更多信息:

规避同源政策的方法

于 2013-09-22T19:30:36.090 回答