I'm using laravel for my backend and trying to send request with jQuery to Instagram api but I'm getting this error while response is OK in Chrome browser inspector
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.
and this is my code to send request
$.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}}"
}
});
I've tried to add Access-Control-Allow-Origin
in my Nginx default.conf
file but that not solved my problem. How can I fix it?