当前位置:Gxlcms > PHP教程 > nginx配置ajax跨域访问phpapi

nginx配置ajax跨域访问phpapi

时间:2021-07-01 10:21:17 帮助过:15人阅读

打开nginx的配置文件nginx.conf,在server中配置一下:

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;

}



以上就介绍了nginx 配置ajax跨域访问php api,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行