codeigniter-restserver icon indicating copy to clipboard operation
codeigniter-restserver copied to clipboard

cross domain request error in IE

Open makkaba opened this issue 9 years ago • 6 comments

above all, thank you for providing us this wonderful library. i have an issue with cross domain request. when i try to request php rest server from another domain, allowed header error occurs only with internet explorer browser(version 11).

SEC7123: Request header content-type was not present in the Access-Control-Allow-Headers list.
SCRIPT7002: SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error

the only solution for this error was paste below code into REST_Controller.php source. at the initial part of constructor.

header('Access-Control-Allow-Origin: *');
      header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
      header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
      $method = $_SERVER['REQUEST_METHOD'];
      if($method == "OPTIONS") {
              die();
       }

i expected cross domain logic in REST_Controller.php and rest.php works properly, because everything look so fine. ex) $config['allow_any_cors_domain'] = TRUE; but it doesn't.

please review this issue. thanks. sorry for poor english.

makkaba avatar Mar 14 '17 12:03 makkaba

Your English is fine :)

I'll take a look.

chriskacerguis avatar Apr 16 '17 21:04 chriskacerguis

How to call delete request what is the url for that

anildsvv14 avatar Apr 27 '17 09:04 anildsvv14

For the delete Request you need to send DELETE instead of POST, GET or PUT

fabianblum avatar Aug 26 '17 22:08 fabianblum

Regarding CORS issue with IE, I had the same problem and solve it using xdomain. I don't use restserver's feature for that.

farukgaric avatar Aug 28 '17 11:08 farukgaric

Not sure, but this issue might have been fixed with commit 4c8a9c3fa0c07d930f3b04ce8ab6e1905dfa8006 ... maybe we should test again with IE.

pbosakov avatar Jan 19 '18 16:01 pbosakov

Gave it a test, and I didn't have any issues with Edge. Going to close this. Feel free to re-open if there is a problem with IE11

chriskacerguis avatar Mar 08 '18 19:03 chriskacerguis