Skip to content

Commit

Permalink
fix: defaultKeyGenerator use value from res.locals.*
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed Jul 12, 2024
1 parent 400a3d6 commit 9aee5e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-camels-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ima/server": patch
---

The default key generator for server cache use parsed value from urlParser method.
4 changes: 2 additions & 2 deletions packages/server/lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ class Entry {
* @return {string} The generated cache key.
*/
function defaultKeyGenerator(request) {
let protocol = request.protocol;
let host = request.get('Host');
let protocol = request.res?.locals?.protocol ?? request.protocol;
let host = request.res?.locals?.host ?? request.get('Host');
let url = request.originalUrl;

return protocol + ':' + host + url;
Expand Down

0 comments on commit 9aee5e3

Please sign in to comment.