I have an AngularJS site that is pulling in posts from WordPress via the plugin "WP REST API (WP API)". I am testing a site on both dev and staging subdomains, and the WP API works on both. However, when I visit one domain, and then switch over to another domain immediately afterward, then the dynamically-generated Access-Control-Allow-Origin is "stuck" on the previous domain to make the API calls. It's not until I refresh the page, that the response header updates to the current domain making the request. Here is what it says in the Chrome console:

XMLHttpRequest cannot load http://wp.domain.tld/wp-json/pages/couples. The 'Access-Control-Allow-Origin' header has a value 'http://staging.domain.tld' that is not equal to the supplied origin. Origin 'http://dev.domain.tld' is therefore not allowed access.

How do I fix this?

  • What auth are you using? Are you also using SSL? it appears not, but just checking. Commented Oct 27, 2015 at 21:21
  • have you got an answer? Commented Dec 3, 2015 at 8:43
  • Did you find a solution to your issue? I also have the same issue. Commented Mar 4, 2016 at 4:51
  • downvoted as it sounds like an angular/browser problem that is not specifically related to wordpress. Commented May 3, 2017 at 6:48
  • I'm seeing this also. I've also tried allowing both the initial (preview host) and the live host in allowed origins but still no luck
    – DJC
    Commented Oct 11, 2017 at 14:48

1 Answer 1


This might be more of an AngularJS question. You can try setting your headers to no-cache. Something like:

var req = {
    headers : {
        "Pragma"        : "no-cache",
        "Expires"       : -1,
        "Cache-Control" : "no-cache"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.