nginx
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET,PUT,POST,DELETE,OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Token,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,X_Requested_With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
return 200;
}
try_files $uri $uri/ /index.php?$query_string;
}
apache
<VirtualHost *:80>
DocumentRoot "D:\XWX\static.demo.sundayhk.com/public"
ServerName static.zsp.yyq.com
<Directory "D:\XWX\static.demo.sundayhk.com/">
AllowOverride all
Require all granted
Header always set Access-Control-Allow-Origin "*"
</Directory>
<IfModule mod_headers.c>
<If "%{REQUEST_METHOD} == 'OPTIONS'">
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET,PUT,POST,DELETE,OPTIONS"
Header always set Access-Control-Allow-Headers "Token,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,X_Requested_With,If-Modified-Since,Cache-Control,Content-Type"
Header always set Access-Control-Max-Age 1728000
Header always set Content-Type "text/plain charset=UTF-8"
RewriteEngine On
RewriteRule .* - [R=200,L]
</If>
</IfModule>
</VirtualHost>