打开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即可。