Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please help me configure codeigniter 4 project, i have trouble accessing api created in codeigniter 4 when using a header with authorization,

the error enter image description here
CORS error 404

I'm using CORS & JWT libraries enter image description here

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Authorization, X-API-KEY, Origin,X-Requested-With, Content-Type, Accept, Access-Control-Requested-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PATCH, PUT, DELETE, get, post");
if($method == "OPTIONS"){

I also try adding this on .htaccess (root/.htaccess and root/public/.htaccess)
RewriteCond %{HTTP:Authorization} ^(.*)
#RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

but when i am not using a authorization from my front-end app the api respond successfuly, but when i am using authenticated api using bearer token it respond cors error.

in the postman my authenticated api works fine but in my vuejs app its not enter image description here

What I have tried:

i tried every solution i heave found in GOOGLE but still have no luck :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900