Response to preflight request doesn t pass access control check

0 votes

I called a REST API on Amazon Web Services using ngResource. But I am getting this error:

XMLHttpRequest cannot load http://server.apiurl.com:8000/s/login?login=facebook. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. Error 405

The Service:


socialMarkt.factory('loginService', ['$resource', function ($resource) {

    var apiAddress = "http://server.apiurl.com:8000/s/login/";

    return $resource(apiAddress, {

        login: "facebook",

        access_token: "@access_token",

        facebook_id: "@facebook_id"

    }, {

        getUser: {

            method: 'POST'

        }

    });

}]);

The Controller:

[...]

loginService.getUser(JSON.stringify(fbObj)),

    function (data) {

        console.log(data);

    },

    function (result) {

        console.error('Error', result.status);

    }

[...]

I have configured the server to accept headers from the origin local host. What am I doing wrong here? Can someone help me with this?

May 7, 2022 in Java-Script by narikkadan
• 63,420 points
1,515 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java-Script

0 votes
1 answer

Error:Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers

Hello @kartik, Access-Control-Allow-Headers does not allow * as accepted value. Instead of ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
1,969 views
0 votes
1 answer

How to manage a redirect request after a jQuery Ajax call?

Hii kartik, You can resolved this issue like ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
28,131 views
0 votes
1 answer

How to access PHP session variables from jQuery function in a .js file?

Hello, You can produce the javascript file via ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
12,238 views
0 votes
1 answer

How to access GET directly from JavaScript?

Hello @kartik, You can first go through: window.location.search It will ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
1,985 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,880 points
2,899 views
0 votes
1 answer

CORS in AWS API Gateway + AWS Lambda

You could try downloading the AWS APIG ...READ MORE

answered Oct 9, 2018 in AWS by Priyaj
• 58,090 points
3,796 views
+3 votes
1 answer

API Gateway CORS: no 'Access-Control-Allow-Origin' header

I get the same problem. I have ...READ MORE

answered Oct 9, 2018 in AWS by Priyaj
• 58,090 points
12,290 views
0 votes
1 answer

What are XMLHttpRequest Object in Ajax?

 As, you are up to ajax so ...READ MORE

answered Jan 31, 2020 in Java-Script by Niroj
• 82,880 points
1,126 views
0 votes
1 answer

jQuery AJAX submit form

There is a simple input mentioned below ...READ MORE

answered Feb 8, 2022 in Java by Soham
• 9,700 points
1,262 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP