nginx 配置Ajax(vue)跨域访问php接口

配置nginx.conf文件

location ~ \.php?($|/)
{
    #try_files $uri =404;
    #handel cosr    by mao
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET';
    add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type';
    fastcgi_pass  unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
}

 

转载于:https://my.oschina.net/lxphemy/blog/3081145

你可能感兴趣的:(nginx 配置Ajax(vue)跨域访问php接口)