0

I have an Only Angular JS Applications hosted in Heroku, it works perfectly, but now, i update the application implementing an $http request (for consuming an API), but when i execute the app i get this:

 error "(razón: falta la cabecera CORS 'Access-Control-Allow-Origin')
 {English: reason: CORS header 'access-control-allow-origin' 
  missing}. (is in spanish)

Already tried with PHP headers like:

header('Access-Control-Allow-Origin: *');

but still the same

I will be grateful if someone could help me.

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Sebas Pinto
  • 265
  • 1
  • 3
  • 15
  • Can you translate the error into English for us? Your overall English is just fine, but most StackOverflow users are English speakers and won't be able to help you if it isn't translated, and even if you do get help from someone it will be less helpful for someone who later gets a similar error. – Ben Hare Jan 13 '17 at 00:20
  • Thanks for your answer @BenHare, You're totally rigtht, i assumed that it was understandable, already edited the post with a translation, English: reason: CORS header 'access-control-allow-origin' missing – Sebas Pinto Jan 13 '17 at 13:22
  • Could you post the PHP code? If you added this header and you're still getting this error, the header is most likely not applied. You can confirm this by pressing F12 in your browser and checking the request. – Bv202 Jan 13 '17 at 13:24
  • Hi @Bv202 , thanks for your answer, As i said, i deployed the app in Heroku, but it's only Angular JS, for backend i'm using Firebase. In the Angular JS deployment tutorial says that only an index.php file must be created for redirect the index.html, so the file (index.php) only contains one line that is: "include_once("index2.html"); ", in this file(index.php) is where i added the headers, but is not working – Sebas Pinto Jan 13 '17 at 15:57
  • @SebasPinto — You have to add the headers to the URL you are requesting with Ajax, not the URL of the HTML document hosting the page the Ajax runs inside. – Quentin Jan 15 '17 at 17:08

0 Answers0