javascript - Angular GET request error, but only on safari iOS -


I am creating a website as a backend for WordPress, and the angular journal as the front I'm using the WordPress json API to get my data up to the front.

Problem

Using angle to get your data from Wordpres json API I made the following service Is:

  this.getPage = function (slug) {return $ http.get ('wordpress / api / get_page /? Slug =' + slug)}  

I use this service in my controller to get the current page

  HTTPService.getPage ('home') .vivet (data) {$ scope.page = Data .page; console.log ();}) .error (function () {console.log (arguments);})  

Then it works fine in all browsers Yes, Safari leaving iOS, if I log the error logic on Safari iOS, I get the following response:

This is Safari Debugger, I have connected my iPhone to my MacBook. The error response I give is the error code. 0 ..

I have tried so far

I entered the 'entry-control-permission-origin' * "Htaccess file, but this work The request does not seem to be done with a relative URL on the same domain, so I do not even think this is a problem.

Does anybody know why this is not working on Safari (iOS only)?

Thanks in advance ...

Edit

Some additional information as requested:

I am sure this is due to the fact that Safari is the only browser in which "third party cookies and other website data" are blocked The policy is to default by default. Actually, this problem should not be exclusive to the Safari iOS, it should also be with Safari on your OSX. I am pretty sure that if this does not happen in your MacBook, then one day you have changed the default setting of "Privacy".

You can try it, open Safari, go to "Preferences" and check "PreCC" under tab if you have the option: "Block cookies and other website data" to "third parties And from advertisers "". This is the first and default option in modern versions of Safari.

In your MacBook it will look like this:

Just confirm this For that it's actually causing your problem: Change this setting to "never" Clear cache and try to recreate that problem again. I am sure you will not be able to reproduce it.

Now, if you set it back on "Block cookies and other website data: From third parties and advertisers" and you first clear the cache , you will see that problem again (With iOS or OSX) After confirming that this is the reason for your problem, set this setting back to "From third parties and advertisers", so that you can reproduce the problem with default settings Able to

Keep in mind that every time you want to test this problem again, it would be better to clean Safary's cache. Otherwise it may be that Safari decides that the site serving APIs can be trusted and you will not be able to reproduce the issue. Therefore, to ensure this, every time you test it, clear the cache .

I believe that the problem of this problem is that Safari wants to ensure that the user had a direct contact with the page in which the "third party content" is served before the main page loads .

I would like to know more about my project to suggest "anticipated" solutions, for example: will the final app be integrated under the same domain as API? Because if this is the case then when you go to production then you should not be on that issue. I mean, if the app you develop will be hosted under: http://whatever.yourDomain.org and the API is going to be part of the same domain ( YourDomain.org ), then you should not have to be at the point of production at all.

On the other hand, if you need to host an API under a different domain, then you have to find a way to "move" Safari. See it:

And this:

I hope That it would be helpful.


Comments