Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Method "Remove" from Authentication Service gives Internal Server Error when using JWT Authentication with Cookies. #606
Steps to reproduce
Cookie should be removed from client, and return an success result.
Cookie IS REMOVED from client, but returns an Internal Server Error:
Tell us about the applicable parts of your setup.
NodeJS version: 8.9.1
Operating System: Windows
Browser Version: Chrome / Postman
Module Loader: Webpack
After some research and debugging, pin pointed the problem to service.js from Feathers-Authentication (inside lib folder), and found out this piece of code:
The problem seems to occur because it tries to find the accessToken on request header 'Authorization', but since I'm using cookies, it can't find and gives the error. After making a small tweak, the problem goes away, but I don't know if it is the right fix:
Well, found another (and at the moment better) solution. I created a hook to run before the remove event from Authentication:
Then register it:
It checks if there isn't a authHeader, and if cookies seems enabled, if it is, extract it and set authHeader. Error is gone, and I can commit it in my project while I don't know if I'm doing something wrong. (: