strapi-community / strapi-plugin-rest-cache

Speed-up HTTP requests with LRU cache.
https://strapi-community.github.io/strapi-plugin-rest-cache/
MIT License
129 stars 29 forks source link

Plugin ignores the header in useHeaders option #81

Closed aa-nasr closed 8 months ago

aa-nasr commented 9 months ago

The plugin seems to ignore the headers specified in useHeaders option based on case-sensitivity. The problem is that the logic inside the filter method that checks for the header in the request doesn't use toLowerCase on the key, although it does exactly that when reading the actual header value in the next line.

Is this intended or is it just a mistake?

https://github.com/strapi-community/strapi-plugin-rest-cache/blob/6906cab0f70b6af9ddf994a35ef2798ac5b6f593/packages/strapi-plugin-rest-cache/server/utils/keys/generateHeadersKey.js#L5

Boegie19 commented 8 months ago

good catch ctx.request.header will always be the in full lowercease. aka everyting in useHeaders is lowercease it works else you are correct and it does not function correctly. let me open a PR to fix this.

aa-nasr commented 8 months ago

Thanks a lot for the effort, @Boegie19