Deedub
Deedub

Reputation: 349

XMLHttpRequest cannot load *…* Origin : * is not allowed by Access-Control-Allow-Origin - ON THE SAME SERVER

Hey folks I am getting this:

XMLHttpRequest cannot load Origin : * is not allowed by Access-Control-Allow-Origin

error. But I don't udnerstand why? one page is on a wordpress page and the other is a static but both are on the same server... or is that not correct?

Upvotes: 0

Views: 1410

Answers (2)

Quentin
Quentin

Reputation: 943108

The origin is determined by:

  • protocol
  • port
  • hostname

All three have to be the same.

The server the page is on is not relevant (beyond it being rare that two URLs on two different servers will share the same hostname).

Note that example.com and www.example.com are different hostnames.

Upvotes: 2

Marc-Emmanuel Ramage
Marc-Emmanuel Ramage

Reputation: 320

The fact that the two pages are on the same server does not matter, it has to be on the same domain.

To bypass this limitation you have to set the header "Access-Control-Allow-Origin" in your response from the server with the value "*"(be careful, it allows all) or a specific domain name "http://myDomain.com".

I hope this helps.

Upvotes: 0

Related Questions