enabling cors in codeigniter ( restserver by @chriskacerguis )

后端 未结 6 729
鱼传尺愫
鱼传尺愫 2020-12-03 12:38

http.get request in agularJs controller works fine when my client app and api are in localhost. when api is moved to server., issue arised.

client side using angular

6条回答
  •  误落风尘
    2020-12-03 13:04

    I've added the following constructor in my controller class

    public function __construct($config = 'rest')
    {
        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
        parent::__construct();
    }
    

提交回复
热议问题