一、apache
1 <IfModule mod_headers.c> 2 setEnvIf Origin "^(.*.eeo13.test)$" AccessControlAllowOrigin=$1 3 Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin 4 Header set Access-Control-Allow-Methods "GET,POST" 5 Header set Access-Control-Allow-Credentials true 6 </IfModule>
二、nginx
location / { if ($http_origin ~* (https?://[^/]*.example.com(:[0-9]+)?|https?://[^/]*.otherdomain.com(:[0-9]+)?)) { add_header 'Access-Control-Allow-Origin' "$http_origin"; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST'; } }