实在很大略,只要在静态资源做事器上,增加一个头信息:
Access-Control-Allow-Origin
本文就apache进行操作,nginx大同小异

首先编辑httpd.conf
找到这行
#LoadModule headers_module modules/mod_headers.so
把#注释符去掉
LoadModule headers_module modules/mod_headers.so
目的是开启apache头信息自定义模块
然后在独立资源域名的虚拟主机添加一行
Header set Access-Control-Allow-Origin
意思是对这个域名的资源进行访问时,添加一个头信息
重启apache
再访问,OK!
<VirtualHost :80>
DocumentRoot "D:/htdocs/erp/public"
ServerName erp.test.com
ServerAlias
AddHandler fcgid-script .php
Header set Access-Control-Allow-Origin
<Directory "D:/htdocs/erp/public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
DirectoryIndex index.php index.html error/index.html
</Directory>
</VirtualHost>