Apache配置跨域

2,306 阅读1分钟

打开httpd.vhosts.conf

<VirtualHost *:80>  
   DocumentRoot "D:\new\api\public"  
   ServerName api.lxb.cc
   <Directory "D:\new\api\public">  
       Options Indexes FollowSymLinks Includes ExecCGI  
       AllowOverride All  
       Require all granted
       Header set Access-Control-Allow-Origin *
       Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
       Header set Access-Control-Allow-Headers "Content-Type"
   </Directory>        
</VirtualHost>

在virtualhost中加入三个header即可。