我得到一个
XMLHttpRequest cannot load http://website2.com/ads/dev_642e92efb79421734881b53e1e1b18b6/5534f8e14d514_1.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://website1.com' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
Website2 是使用 nginx 配置的:
server {
listen 80;
server_name website2.com;
root /var/www/website2;
index index.php index.html index.htm;
#try_files $uri $uri/ /index.php?$args;
client_max_body_size 20M;
location /ads {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
try_files $uri $uri/ /index.php?$args;
}
location / {
try_files $uri $uri/ /index.php?$args;
# proxy_pass http://127.0.0.1:2368/;
# proxy_set_header …Run Code Online (Sandbox Code Playgroud)