Inconsistency with WPJSON API in getting content from posts
-
I’m using the WP JSON API to get content on my website. However, sometimes it works and sometimes it doesn’t. Half the time I get this error in the console, both when I’m working locally and when I’m on the server.
XMLHttpRequest cannot load http://www.example.com/blog/wp-json/posts The ‘Access-Control-Allow-Origin’ header has a value ‘http://localhost’ that is not equal to the supplied origin. Origin localhost is not allowed access
I’m using AngularJS’s $http get call to access the wp-json API? Half the time it returns data, the other half it gives that error. I’m confused on why it sometimes works and sometimes doesn’t. When I add the prefix www, it works though, but I do want www in the url. Any ideas on why this is happening and how to fix this?
The topic ‘Inconsistency with WPJSON API in getting content from posts’ is closed to new replies.