Welcome Guest, Not a member yet? Register   Sign In
auto routing (improved), CORS and Authorization header
#1

(This post was last modified: 11-04-2022, 04:27 AM by codeus.)

When sending a POST request (cross-origin) which includes an Authorization HTTP header, the response to OPTIONS request is a 404 - CORS Missing Allow Origin. 
If the Authorization HTTP header is omitted, the request reaches Satellite:postActivate. 
However, when the route is added to Config/Routes.php the request works fine-:


PHP Code:
$routes->options('/satellite/activate''Satellite::postActivate');
$routes->post('/satellite/activate''Satellite::postActivate'); 
I suspect I'm missing something here, but the CORS handling code (Access-Control-Allow-Credentials, Expose-Headers etc) must be OK - the request works, but only if the route is not Auto Routing Improved. Or the Auth header is not used.
Thanks for any response!
Smile
Reply
#2

If you want to get OPTION request, you need the method like optionActivate() for it in your controller.
That's it.
Reply
#3

(11-04-2022, 04:12 PM)kenjis Wrote: If you want to get OPTION request, you need the method like optionActivate() for it in your controller.
That's it.
Thanks - that was indeed the problem.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB