Hi there 👋🏻
Today I solved interesting problem and I want to share the solution. I was sending HTTP request to API with authorization token but API was always returning “401, Token Not Found” error. When I check the server logs, I found out that the token was really not sent. It’s really interesting. I searched for a while and found this interesting comment on Github.
I was sending my request to /api/locations endpoint but endpoint was /api/locations/ with slash. Server was responding with 301 redirect to /api/locations/. After the redirect, Swift doesn’t send authorization header because of some security reasons. Thus, my server can’t find my JWT token and always return 401.
I hope this will help you. Have a nice day 😊