Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  126] [ 7]  / answers: 1 / hits: 23809  / 7 Years ago, tue, september 26, 2017, 12:00:00

I am getting an error like:


origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. 

This error occurs only when the design is integrated in codeigniter.


Please note who all added this question as duplicate.
my question is not a duplicate question of this .
My solution is added as the comment.
Since, some geeks who think that, its a duplicate question, and reviewd it like so, I am not able to answer my own question. Once I get the privilage to add so, I will move the comment to answer.


Thankyou


More From » php

 Answers
51

You need to add headers in Your requested page:



  // headers
header(Access-Control-Allow-Origin: *);
header(Access-Control-Allow-Methods: POST);
header(Access-Control-Allow-Headers: Origin, Methods, Content-Type);


EDIT



in codeigniter:



$this->output
->set_content_type(Access-Control-Allow-Origin: *)
->set_content_type(Access-Control-Allow-Methods: POST)
->set_content_type(Access-Control-Allow-Headers: Origin, Methods, Content-Type)

[#56380] Saturday, September 23, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cartersinceren

Total Points: 442
Total Questions: 116
Total Answers: 106

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
;