【发布时间】:2017-05-14 16:10:05
【问题描述】:
我在后端使用 laravel,并尝试使用 jQuery 向 Instagram api 发送请求,但在 Chrome 浏览器检查器中响应正常时出现此错误
test?code=a3679b3…:1 XMLHttpRequest cannot load https://api.instagram.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not allowed access.
这是我发送请求的代码
$.ajax({
method: 'POST',
url: 'https://api.instagram.com/oauth/access_token',
data: {
client_id: "client_id",
client_secret: "client_secret",
grant_type: "authorization_code",
redirect_uri: "example.com",
code: "{{$code}}"
}
});
我尝试在我的 Nginx default.conf 文件中添加 Access-Control-Allow-Origin,但这并没有解决我的问题。我该如何解决?
【问题讨论】: