0

I have an angular 4 app talking to a php script that resides on WAMP (www folder) they are both on my local machine. I get this error logged in the browser when i hit the script.

No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:4200' is therefore not allowed access. 
The response had HTTP status code 404.

I know its because i am trying to access from localhost to localhost that this problem occurs.

I did a bit of reading and it appears i need to fix it from wamp server. Not sure how to do that on wamp.

georgeawg
  • 47,985
  • 13
  • 70
  • 91
Joshua Majebi
  • 1,000
  • 4
  • 15
  • 31

1 Answers1

5

As commented, the problem is that you need to allow all origins from the script.

//at the very begining of your php script.
header('Access-Control-Allow-Origin: *'); 
yBrodsky
  • 4,852
  • 3
  • 17
  • 31