我正在使用dokuwiki的freePHPchat插件。当我使用MYIP http://ServerIP/dokuwiki/doku.php?id=chat2时,聊天应用程序加载正常,但当我使用我的DNS(例如http://MyDomainName/doku.php?id=chat2)时,Chrome浏览器会抛出“拒绝获取不安全的标题”X-JSON“并且聊天没有t load。
我已将以下内容添加到我的apache.conf中。正如其他文章所述。仍然没有运气。任何人都可以帮我解决这个问题吗?
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
#Header set Access-Control-Allow-Headers "Origin, x-requested-with, Content-Type, Content-Type, x-json, Accept"
#Header set Access-Control-Allow-Methods "GET,POST,OPTIONS"
#Header set Access-Control-Allow-Headers "Content-Type, x-prototype-version, x-requested-with, JSON, X-JSON"
</Directory>
以下是我的access.log
SourceIP - - [07/Sep/2016:20:00:18 +0000] "POST /dokuwiki/lib/plugins/freechat/backend.php HTTP/1.1" 200 490 "ServerIP/dokuwiki/doku.php?id=chat2" "Mozilla/5.0 (X11; CrOS x86_64 8350.68.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
SourceIP - - [07/Sep/2016:20:00:18 +0000] "OPTIONS /dokuwiki/lib/plugins/freechat/backend.php?pfc_ajax=1&f=loadChat HTTP/1.1" 200 699 "MyDomainName/doku.php?id=chat2" "Mozilla/5.0 (X11; CrOS x86_64 8350.68.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
SourceIP - - [07/Sep/2016:20:00:18 +0000] "GET /dokuwiki/lib/plugins/freechat/backend.php?pfc_ajax=1&f=loadChat HTTP/1.1" 200 698 "MyDomain/doku.php?id=chat2" "Mozilla/5.0 (X11; CrOS x86_64 8350.68.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
答案 0 :(得分:1)
将 X-JSON 添加到 Access-Control-Expose-Headers 。
Header set Access-Control-Expose-Headers "Content-Length, X-JSON"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Accept, Content-Type, X-Forwarded-For, X-Prototype-Version, X-Requested-With"
Header set Access-Control-Allow-Methods "GET, OPTIONS, PUT, POST"