1

I am facing the strange problem on the wordpress website . What is really happening that i have a form in the wordpress website main page and the form submit the data in the Codeigniter Controller function .

Whenever i submit the form i got this message

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://xxx/ci/user/signup/. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Where as if i putt the same code in the php file at this path

http://xxx/ci/signup.php

It submit the data sucessfully and everything goes well . But whenever i try to submit data from the wordpress site it gives me that error . I also check the htaccess file and limit it worpdress only commands .

I am not getting why i am getting this issue when i am using it on same domain and both time i use http to access the url .

Cœur
  • 37,241
  • 25
  • 195
  • 267
Uahmed
  • 1,847
  • 5
  • 29
  • 45

2 Answers2

2

add these header in the server side script.i.e in codeigniter page header

header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST');

dev
  • 496
  • 1
  • 5
  • 18
0

modify config/config.php file like below :

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");

$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];

$config['base_url'] .=str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

(replace baseurl method with top code)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Pirooz Jenabi
  • 440
  • 5
  • 7