Search Posts

Category: cors

(Access-Control-Allow-Origin – CORS issue when fetching data from 2 URL for promises

So I have promises in AngularJS which fetch data from 2 URLs. promises.push(loadingJson(‘example.com/1.json’)); promises.push(loadingJson(‘example.com/2.json’)); $q.all(promises).then(function(resultList){ }, function(errList){ }); After running the page (using Promises) in web server, it gives error “Origin ‘www.abc’ not allowed by Access-Control-Allow-Origin.” and “XMLHttpRequest cannot load ‘1.json’ and ‘2.json’ due to access control checks”. For Jquery GET method I can use JSONP to solve the error. But is there a way that can solve it in angularJS promises? Source: AngularJS

AngularJS Response Header Seen In Console Not in $http.get header object [duplicate]

This question already has an answer here: Why is Access-Control-Expose-Headers needed? 2 answers I see the response headers in chrome’s network tab. Content-Disposition: attachment; filename=”testfile.prn” However when I look at the headers in AngularJS, the following code prints: Output: Headers: generate-content.js:91 {content-type: “application/octet-stream”} Code: $http.get(URL, {withCredentials: true, timeout: 100000}) .success(function(results, status, headers){ … console.log(“Headers: “) console.log(headers()) … }).error(function(err){ console.error(err); }); I’m using a Sails.js backend and no matter what additional headers I put in the […]

Call Web API in AngularJS (with CORS) works in Desktop Browsers but not in Chrome on Android

First of all when user sign in he gets a custom authorization token (base64) and after that this token must be included in our custom HTTP header (X-Custom-Auth) for calling other Web APIs. It works in any browsers I have tested but not in Chrome on my android phone! In android chrome when I press Signin button it actually does everything correct and even the authorization token is received, It’s stored in local session and […]

Response for preflight is invalid (redirect), cross-origin requests are being blocked [duplicate]

This question already has an answer here: XMLHttpRequest cannot load https://www.[website].com/ 6 answers How to enable CORS in AngularJs 6 answers I need to consult some zip codes in the viacep API (https://viacep.com.br), when I execute the get below: vm.buscarCEP = function(){ const cep = vm.empresaResponsavel.cep //RECEBE CEP DO CAMPO const apiViaCep = `http://viacep.com.br/ws/${cep}/json/` $http.get(apiViaCep).then(function(resp) { //CONSULTA NA API vm.empresaResponsavel.logradouro = resp.data.logradouro vm.empresaResponsavel.bairro = resp.data.bairro vm.empresaResponsavel.cidade = resp.data.localidade vm.empresaResponsavel.uf = resp.data.uf }).catch(function(resp) { console.log(resp.data.errors) console.log(“CEP […]

Why headers is undefined in angularjs $http post

I’ve tried to get response headers in AngularJS. Problem is headers return undefined when I tried with AngularJS as following codes, but when I tried with https://www.hurl.it, it’s working. Please let me know how to do it. this.fetchLoginMule = (path, params, accessToken) => { var deferred = $q.defer(); $http({ method: ‘POST’, url: $rootScope.api + path + ‘&accessToken=’ + accessToken, headers: { ‘appId’: ‘mm.customer’, ‘appVersion’: ‘3.31.34-5-gf8e600c’, ‘versionCode’: ‘0.1’, ‘deviceId’: ‘1736837382023722’, ‘userLanguage’: ‘en’, ‘notificationTrackingId’: ‘123’, ‘securityCounter’: ‘123’, […]

Cors error while using passport google oauth2 in nodejs with angularjs

I am using angularjs with nodejs at the backend. When I make the call to backend on http://localhost:3000/auth/google On back end I redirect it to Google using passportjs. But it shows me error in my browser that can not redirect from http://localhost:3000/auth/google to https://’google api link’ no access-allow-origin header found on request site. If I click on that ‘google api link’ from my browser it works fine it takes me to the google auth dailog […]

about CORS between mobile application and web application

I encountered CORS error that when I fetch api from my web application. Oddly, that problem not occurred when I fetch that same API with POSTMAN and Mobile App (iOs & Android). That’s why I’m about to talk my backend/server engineer to open CORS my web app IP address. But I’m concerned that I have no answer to explain him when he ask me why POSTMAN & Mobile App can be able to call that […]

angularjs https get Access-Control-Allow-Origin error [duplicate]

This question already has an answer here: XMLHttpRequest cannot load https://www.[website].com/ 6 answers I’m trying to GET json from an open url https://www.instagram.com/donaldduck/?__a=1 but I’m getting this error :”Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header has a value ‘null’ that is not equal to the supplied origin. Origin ‘null’ is therefore not allowed access.” app.controller(‘instaCtrl’, function($scope, $http) { $http.get(“https://www.instagram.com/donaldduck/?__a=1”) .then(function(response) { $scope.arragne = response.data; //$scope.media = $scope.arragne.user.media.nodes; console.log(response); }); }); […]

CORS error while sending request from Browser to play server even after sending CORS header

I have a REST API developed using Play Framework/Java and front end developed in Angular JS. I am trying to call a POST method fron the Angular Client to the server using the following code: $scope.login = function () { console.log(‘login called’); var loginURL = ‘http://localhost:9000/login’; var loginInfo = { ’email’: $scope.email, ‘password’: $scope.password }; $http({ url: loginURL, method: ‘POST’, data: loginInfo, headers: { ‘Content-Type’: ‘application/json’ } }).then(function (response) { console.log(‘SUCCESS: ‘ + JSON.stringify(response)); $scope.greeting […]

Next Page »