Filter Cors now working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Filter Cors now working (/showthread.php?tid=82262) |
Filter Cors now working - Thiaxl - 06-26-2022 I have the following cors filter: PHP Code: ... And in Filter class: PHP Code: ... But not work. It only works if I add the headers into index.php in the public folder. How to resolve this? RE: Filter Cors now working - includebeer - 07-02-2022 You just defined an alias, you're not calling you filter anywhere. That's why it's not working. You need to add the filter to the 'before' or 'after' array of the $globals property. See https://codeigniter.com/user_guide/incoming/filters.html#globals In you case it would be in the 'before' array, like that: PHP Code: public $globals = [ RE: Filter Cors now working - InsiteFX - 07-02-2022 Donot us this in a live server! Access-Control-Allow-Origin: * Use: Access-Control-Allow-Origin: https://yourDomain.com |