-
-
Save jingmian/157e9139f7e222b8987435a6824e354c to your computer and use it in GitHub Desktop.
http协议
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 一个TCP可以包含多个http请求 | |
| 需要在服务器上设置返回给客户端。其实客户端跨域访问服务器的时候,已经得到返回值了,服务器是不限制跨域的,是浏览器把返回来的数据认为不在同一个服务器上返回的数据不安全,所以给忽略并提示错误 | |
| “Access-Control-Allow-Origin”: "*" //允许来之域名为所有的请求 | |
| “Access-Control-Allow-Headers", "Origin,No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With, userId, token" | |
| ”Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE" //请求允许的方法 | |
| “Access-Control-Max-Ag", "3600" //身份认证(预检)后,xxS以内发送请求不在需要预检,既可以直接跳过预检,进行请求。 | |
| content-type:以下3种类型不需要申请xxs预请求 | |
| multipart/form-data | |
| text/plain | |
| application/x-www-form-urlencoded | |
| <?php | |
| header("ACCESS-CONTROL-ALLOW-ORIGIN:http://www.guitoo.cc"); | |
| 允许guitoo.cc网站来的请求访问 | |
| 也可以使用*通配符,来允许所有的域名访问 | |
| header("ALLOW-CONTROL-ALLOW-ORIGIN:*"); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment