kwhitley / apicache

Simple API-caching middleware for Express/Node.
MIT License
1.24k stars 193 forks source link

Dont serve cache if API authorization fails #225

Open ZaidWaseem10 opened 4 years ago

ZaidWaseem10 commented 4 years ago

I have an API KEY header with each request. Generally whats happening is that if the first request has correct api key, the response will be cached. Now if anyone makes a request to the same endpoint without correct api key, the cache will also be served. It fails the security measures taken for the endpoint. Is there any way to validate API-KEY in each and every request? even though the response is cached.

josedev999 commented 4 years ago

@ZaidWaseem10 I think it is matter of how you put middlewares in order. You need to put authorization middleware in front of cache middleware.