php – How to work with a remote server using ngresource

Question:

There is a site written in angular, using rest api, api gives json, ngresource takes it, everything is fine, as long as all this action takes place on one server.

Ngresource works on ajax, therefore, when trying to receive or send data to another server, there will be an error in the rights. You can use jsonP, but then how would you have to rewrite

 var resource = $resource(url,
                {callback: "JSON_CALLBACK"},
                {
                    get: {method: "JSONP"}
                }
            );

The whole meaning of rest api is lost, it seems to use the headers post, get, delete, put.

And the question came up when I tried to build a mobile application in cordova + ionic.

You can, of course, disable Access-Control-Allow-Origin on the server.

<?php header('Access-Control-Allow-Origin: *'); ?>

If someone knows the right way out, tell me.

Answer:

The chrome plugin helped me a lot in debugging ionic applications: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi

Scroll to Top