简体   繁体   中英

Apache No 'Access-Control-Allow-Origin' header

I tried to search between old questions but i didn't find how to figure out my issue I have a LF site; all works pretty good; when i go on http://localhost:8080/ i have no problem and no error is shown on firebug and/or chrome console I configured then, an Apache HTTP Server. All seems to me correct but when i try the URL http://localhost I see my site but some resources are not loaded. In chrome console (but also in firebug) I get the following error:

2(index):1 Font from origin ' http://localhost:8080 ' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost ' is therefore not allowed access.

I don't know how to figure out this issue. It seems to me an Apache configuration mistake. This is my virtual host configuration:

<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>

It seems to me all correct... is there any other option i should put?

Do you have any idea where I'm wrong?

Thank you

Angelo

您仅在端口80上设置了CORS标头,但是跨域部分是从端口80到端口8080 -您应将Header set ...移到虚拟主机上下文之外,或将其复制到8080 vhost中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM