简体   繁体   中英

Getting a 401 http response (sometimes) while request is proper

i've been facing a problem lately and i don't know how to handle it, or even what the problem might be coming from.

Tools:

-MYSQL(for data base)

-JAVA EE web application(to service as back-end)

-Jersey 2.26 dependency (to service as API on top of web application /CORS filter implemented)

-Apache Tomcat/7.0.69 ( as web server where web app sets )

-Angular 4 ( as website and client to the API)

-CentOS Linux release 7.3 (Core) (Server operating system )

Problem:

once the request is sent to the API ( to a specific secured Endpoint ) lets call it customers, Sometimes the response is 401 Unauthorized, and in other times it works just fine, from the angular website for instance, if press f12 and follow the requests, i send the same request again ( for the one i got 401 for ) but this time it works, the JWT is valid and it works just fine, and its not that there is too many request going to the server, even if its few sometimes i get 401, but most of the time it works great.

the only thing in the code that can return 401 is the authentication filter, which checks the validity of token, but it looks fine to me.

i checked this article that talks about 401 response, but still, its hard for me to grasp the idea why it works good sometimes and not work other times for the same request. i get the 401 while checking with the website and also with checking with postman. so i guess it's not a cache or cookies thing, but i might be wrong to assume this.

any ideas on what might be wrong ? or where should i be checking for bugs or errors ?

Thanks allot

将tomcat安全性设置为false。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM