@scayle/storefront-nuxt 8.62.8 → 8.62.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 8.62.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed the redirects middleware applying the cached redirect of one URL to every URL that differs from it only in its query params. With `redirects.queryParamWhitelist` set, `/sale?campaign=summer`, `/sale?campaign=winter` and `/sale` shared one redirect cache entry, because unstorage cuts a key at the first `?`. Whichever URL was looked up first decided the result for all of them until the entry expired, so the bare page could get a campaign redirect, and a cached "no redirect" hid the redirect of another campaign. Each lookup URL now has its own cache entry.
8
+
9
+ The middleware also no longer follows a cached redirect whose target is the requested URL. With the shared entry, a redirect from `/search?query=trousers` to `/search?query=pants` sent every search to `?query=pants`, which then redirected to itself.
10
+
11
+ **Dependencies**
12
+
13
+ **@scayle/storefront-core v8.62.9**
14
+
15
+ - No changes in this release.
16
+
3
17
  ## 8.62.8
4
18
 
5
19
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "8.62.8",
3
+ "version": "8.62.9",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.13"
package/dist/module.mjs CHANGED
@@ -57,7 +57,7 @@ export default {
57
57
  }`;
58
58
  }
59
59
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
60
- const PACKAGE_VERSION = "8.62.8";
60
+ const PACKAGE_VERSION = "8.62.9";
61
61
  const logger = createConsola({
62
62
  fancy: true,
63
63
  formatOptions: {
@@ -6,12 +6,16 @@ const REDIS_REDIRECT_PREFIX = ":REDIRECT";
6
6
  const REDIRECT_NOT_SET = "REDIRECT_NOT_SET";
7
7
  const REDIRECT_CACHE_TTL = 120;
8
8
  async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCache, log, waitUntil) {
9
+ const cacheKey = encodeURIComponent(sourceUrl);
9
10
  try {
10
- const cachedResult = await redirectCache.get(sourceUrl);
11
+ const cachedResult = await redirectCache.get(cacheKey);
11
12
  if (cachedResult) {
12
13
  if (cachedResult === REDIRECT_NOT_SET) {
13
14
  return null;
14
15
  }
16
+ if (cachedResult.target === sourceUrl) {
17
+ return null;
18
+ }
15
19
  return cachedResult;
16
20
  }
17
21
  } catch (e) {
@@ -32,13 +36,13 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
32
36
  };
33
37
  if (!sapiResult || !isValidRedirect(sapiResult)) {
34
38
  waitUntil(
35
- redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch((e) => log.error("Error saving redirect to cache", e))
39
+ redirectCache.set(cacheKey, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch((e) => log.error("Error saving redirect to cache", e))
36
40
  );
37
41
  return null;
38
42
  }
39
43
  waitUntil(
40
44
  redirectCache.set(
41
- sapiResult.source,
45
+ cacheKey,
42
46
  {
43
47
  target: sapiResult.target,
44
48
  statusCode: sapiResult.statusCode
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "8.62.8",
4
+ "version": "8.62.9",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -79,7 +79,7 @@
79
79
  "dependencies": {
80
80
  "@opentelemetry/api": "^1.9.1",
81
81
  "@scayle/h3-session": "0.7.2",
82
- "@scayle/storefront-core": "8.62.8",
82
+ "@scayle/storefront-core": "8.62.9",
83
83
  "@scayle/unstorage-compression-driver": "1.6.0",
84
84
  "@vercel/nft": "1.11.0",
85
85
  "@vueuse/core": "15.0.0",