-1

I am developing my app using Angularjs for front end and php mysql for backend. in php i am using slim framework. Things went smoothly while i was developing on my local machine and testing on localhost. However when I uploaded the code to a free shared hosting, all my rest calls stopped workng and started getting the following error.

XMLHttpRequest cannot load http://error404.myhostingprovider.com/?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myfreehosingdomain.com' is therefore not allowed access.

Can anybody please tell me what is going on.

chandings
  • 549
  • 3
  • 9
  • 23
  • possible duplicate of ["No 'Access-Control-Allow-Origin' header is present on the requested resource"](http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource) – Kevin Kopf Dec 17 '14 at 01:57
  • not a duplicate as i am making xhr request from the same domain. – chandings Dec 17 '14 at 05:23

2 Answers2

0

In short, websites have to be careful about including content from other websites, because that content may be undesired / evil or changed en-route. Websites are generally responsible for whitelisting cross-domain requests they are expecting to make for the sake of the client's security.

I would suggest that you read up on a Browser Content Security Policy: https://en.wikipedia.org/wiki/Content_Security_Policy.

Then take a look at how to handle this case in the slim framework. This might be a good starting point: http://help.slimframework.com/discussions/problems/810-no-subject

bcr
  • 1,328
  • 11
  • 27
0

In my case this was because I was being redirected to an erro404 page outside my domain. The actual error was due to other factors (no mysql native driver in my case).

chandings
  • 549
  • 3
  • 9
  • 23