Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

XMLHttpRequest cannot load error on accessing MEAN.js API through IONIC app #977

Closed
rohitvinay opened this issue Oct 12, 2015 · 1 comment

Comments

@rohitvinay
Copy link

I am developing an ionic application, trying to access API of MEAN.JS application which is as below which is a link to encoded JSON

https://damp-dawn-2579.herokuapp.com/api/foods
The factory service of my application accesses the above link but gets an error

XMLHttpRequest cannot load http://localhost:3000/api/foods. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
Factory Service

.factory('Foods', ['$resource',
function($resource) {
return $resource('https://damp-dawn-2579.herokuapp.com/api/foods/:foodId', { foodId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
])
How do i overcome this? Thank you

@codydaig
Copy link
Member

You need to enable cors.
https://www.npmjs.com/package/cors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants