Virtuallified / REST-Api_JWT_CodeIgniter3

CodeIgniter 3 - REST API Integration with JWT (JSON Web Tokens)
MIT License
27 stars 20 forks source link

How to solve cors error in this structure? #4

Open Kajal81198 opened 1 year ago

Kajal81198 commented 1 year ago

I just make a login api and i want to fetch that api from my react application but it gives me cors error. so how can i solve this issue in this structure.

Virtuallified commented 1 year ago

Hi @Kajal81198 , Please add the below lines at the beginning of your php scripts.

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: X-Requested-With');

I hope that will resolve your problem.

Kajal81198 commented 1 year ago

When I remove rest controller and extend only ci controller then it works otherwise it won't work. So how can solve this problem with rest controller...?

On Mon, May 15, 2023, 4:45 PM Subhradip D. @.***> wrote:

Hi @Kajal81198 https://github.com/Kajal81198 , Please add the below lines at the beginning of your php scripts.

header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); header('Access-Control-Allow-Headers: X-Requested-With');

I hope that will resolve your problem.

— Reply to this email directly, view it on GitHub https://github.com/Virtuallified/REST-Api_JWT_CodeIgniter3/issues/4#issuecomment-1547663835, or unsubscribe https://github.com/notifications/unsubscribe-auth/APJ3DTPPHQWFQGSAANCSN6DXGIF5DANCNFSM6AAAAAAXVTAPIQ . You are receiving this because you were mentioned.Message ID: @.***>