Reputation: 24053
I am not familiar with this issue and I hope you can help.
I am developing a web application. My Backend api endpoints sits under http://www.example.com/api where my front end application located in http://www.otherdomain.com.
The problem is that I get cross domain problems when I am trying to make ajax requests.
I am using AngularJS in the frontend and RoR (rails) on the backend.
Do you have any idea how to fix it?
Upvotes: 0
Views: 2074
Reputation: 10121
The best solution would probably be to set a reverse proxy
using nginx
so that the requests can be received by a local server, on your local domain, and reverse-proxied to the destination server exactly as they were received (CORS limitation do not apply on servers).
Another solution is this neat Javascript proxy: https://github.com/jpillora/xdomain
Upvotes: 0
Reputation: 495
We encountered this several times before in our PHP & Java Backend Api's. But our solution was always to include this to your api server header: Access-Control-Allow-Origin "*"
Upvotes: 0
Reputation: 193
For security reasons browsers are blocking ajax request for another domain(you can read here). But you can try to use $http.jsonp()
Upvotes: 2