【发布时间】:2023-03-20 19:53:01
【问题描述】:
allow-control-allow-origin : * 标头存在于 API 响应中,但浏览器仍显示错误。网络 403 错误。
这是来自 API 的示例响应标头:
Access-Control-Allow-Headers: Origin,X-Requested-With,X-CSRF-Token,Content-Type
Access-Control-Allow-Methods: GET,POST,PUT,DELETE
Access-Control-Allow-Origin: *
Cache-Control: no-cache="set-cookie"
Connection: keep-alive
Content-Length: 870
Content-Type: text/plain;charset=UTF-8
Date: Sat, 28 Nov 2015 17:56:46 GMT
Server: Apache-Coyote/1.1
Set-Cookie: AWSELB=6B492DE10EE
Firebug 中的错误:
"NetworkError: 403 Forbidden - https://xyz.....s"
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://xyz..... (Reason: CORS header 'Access-Control-Allow-Origin' missing).
请求 - AngularJS
var config = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"Apikey": "*************"
}
}
$http.post(URL, data, config)
.success(function (data, status, headers, config) {
//function
})
【问题讨论】:
-
和我给出的一样...不是示例响应..它是来自服务器的实际响应头。
-
这是来自服务器的响应。它是普通的 API 服务器,我们无法更改服务器中的任何内容。有没有可能在客户端做代码?请指教。
-
我已添加请求..请检查
标签: jquery angularjs http http-headers cors