本文介绍了飞行前响应在角度中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用apiary api进行测试,如下所示:
I am trying to perform test using apiary api as the following:
$scope.createAsset = function () {
$http({
method: 'POST',
url: 'http://polls.apiblueprint.org/createStory',
headers: {'Access-Control-Allow-Origin': '*'}
});
}
养蜂场:
FORMAT: 1A
HOST: http://polls.apiblueprint.org/
# BulBulTest
BulBulTest is a simple API for testing.
## Create story [/createStory]
### Create story [POST]
+ Response 200 (application/json)
{
"Status": "Story created sucessfully",
"published_at": "2015-08-05T08:40:51.620Z",
"publisher": "Johm Smith"
}
,即使设置了 allow-origin
,我仍然收到错误消息.
and I get error even after setting the allow-origin
.
推荐答案
您对CORS : Access-Control-Allow-Origin
标头来自服务器,而不是客户端.服务器决定是否允许跨域调用.
You have a misunderstanding of CORS: The Access-Control-Allow-Origin
header comes from the server, not the client. It's the server that decides whether to allow a cross-origin call.
在服务器不支持的跨域调用中,客户端代码中您无能为力.
There's nothing you can do in your client-side code to enable a cross-origin call if the server doesn't support it.
这篇关于飞行前响应在角度中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!