我试图在旧问题之间进行搜索,但我没有找到如何解决我的问题 我有一个LF网站;一切都很好;当我继续http://localhost:8080/时,我没有问题,并且在firebug和/或chrome控制台上没有显示错误 我配置了一个Apache HTTP Server。在我看来,所有这些都是正确的,但是当我尝试使用网址http://localhost时,我看到了我的网站,但是没有加载某些资源。在chrome控制台(但也在firebug中)我收到以下错误:
2(索引):1来自原点的字体' http://localhost:8080'已被封锁 从跨源资源共享政策加载:否 '访问控制允许来源'标题出现在请求的上 资源。起源' http://localhost'因此不允许访问。
我不知道如何解决这个问题。在我看来,Apache配置错误。 这是我的虚拟主机配置:
<VirtualHost *:80>
#CORS
<Directory "/var/www/">
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Always set these headers.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
ProxyPass /c http://localhost:8080/c
ProxyPassReverse /c http://localhost:8080/c
ProxyPass /si http://localhost:8080/si
ProxyPassReverse /si http://localhost:8080/si
ProxyPass /image http://localhost:8080/image
ProxyPassReverse /image http://localhost:8080/image
ProxyPass /documents http://localhost:8080/documents
ProxyPassReverse /documents http://localhost:8080/documents
ProxyPass /html http://localhost:8080/html
ProxyPassReverse /html http://localhost:8080/html
ProxyPass /sprite http://localhost:8080/sprite
ProxyPassReverse /sprite http://localhost:8080/sprite
ProxyPass /combo http://localhost:8080/combo
ProxyPassReverse /combo http://localhost:8080/combo
ProxyPass / http://localhost:8080/web/mySimpleLog
ProxyPassReverse / http://localhost:8080/web/mySimpleLog
ErrorLog logs/mySimpleLog-error_log
CustomLog logs/mySimpleLog-access_log common
</VirtualHost>
在我看来,一切都正确......我还有其他选择吗?
你知道我哪里错了吗?
谢谢
安吉洛
答案 0 :(得分:0)
您只在端口80上设置CORS标头,但是跨源部分是从端口80到端口8080 - 您应该移动标头集...在虚拟主机上下文之外或在8080中复制它虚拟主机。