@sitecore-jss/sitecore-jss-nextjs 22.8.0-canary.2 → 22.8.0-canary.3

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.
@@ -24,11 +24,17 @@ class MiddlewareBase {
24
24
  * @returns {boolean} is prefetch
25
25
  */
26
26
  isPrefetch(req) {
27
- return (
28
- // eslint-disable-next-line prettier/prettier
29
- req.headers.get('purpose') === 'prefetch' || // Pages Router
30
- req.headers.get('Next-Router-Prefetch') === '1' // App Router
31
- );
27
+ const isMobile = req.headers.get('sec-ch-ua-mobile') === '?1';
28
+ const purpose = req.headers.get('purpose');
29
+ const nextRouterPrefetch = req.headers.get('Next-Router-Prefetch');
30
+ const middlewarePrefetch = req.headers.get('x-middleware-prefetch');
31
+ // Mobile requests often include 'prefetch' headers even during real navigations.
32
+ // We rely on 'x-middleware-prefetch' to more accurately identify actual prefetches on mobile.
33
+ if (isMobile && middlewarePrefetch === '1') {
34
+ return false;
35
+ }
36
+ // Otherwise, standard prefetch detection
37
+ return purpose === 'prefetch' || nextRouterPrefetch === '1' || middlewarePrefetch === '1';
32
38
  }
33
39
  excludeRoute(pathname) {
34
40
  var _a, _b;
@@ -21,11 +21,17 @@ export class MiddlewareBase {
21
21
  * @returns {boolean} is prefetch
22
22
  */
23
23
  isPrefetch(req) {
24
- return (
25
- // eslint-disable-next-line prettier/prettier
26
- req.headers.get('purpose') === 'prefetch' || // Pages Router
27
- req.headers.get('Next-Router-Prefetch') === '1' // App Router
28
- );
24
+ const isMobile = req.headers.get('sec-ch-ua-mobile') === '?1';
25
+ const purpose = req.headers.get('purpose');
26
+ const nextRouterPrefetch = req.headers.get('Next-Router-Prefetch');
27
+ const middlewarePrefetch = req.headers.get('x-middleware-prefetch');
28
+ // Mobile requests often include 'prefetch' headers even during real navigations.
29
+ // We rely on 'x-middleware-prefetch' to more accurately identify actual prefetches on mobile.
30
+ if (isMobile && middlewarePrefetch === '1') {
31
+ return false;
32
+ }
33
+ // Otherwise, standard prefetch detection
34
+ return purpose === 'prefetch' || nextRouterPrefetch === '1' || middlewarePrefetch === '1';
29
35
  }
30
36
  excludeRoute(pathname) {
31
37
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.8.0-canary.2",
3
+ "version": "22.8.0-canary.3",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -72,16 +72,16 @@
72
72
  "react-dom": "^19.1.0"
73
73
  },
74
74
  "dependencies": {
75
- "@sitecore-jss/sitecore-jss": "22.8.0-canary.2",
76
- "@sitecore-jss/sitecore-jss-dev-tools": "22.8.0-canary.2",
77
- "@sitecore-jss/sitecore-jss-react": "22.8.0-canary.2",
75
+ "@sitecore-jss/sitecore-jss": "22.8.0-canary.3",
76
+ "@sitecore-jss/sitecore-jss-dev-tools": "22.8.0-canary.3",
77
+ "@sitecore-jss/sitecore-jss-react": "22.8.0-canary.3",
78
78
  "@vercel/kv": "^0.2.1",
79
79
  "regex-parser": "^2.2.11",
80
80
  "sync-disk-cache": "^2.1.0"
81
81
  },
82
82
  "description": "",
83
83
  "types": "types/index.d.ts",
84
- "gitHead": "458ef0e5455d807e58e0219bb0deebc42fa0b3e2",
84
+ "gitHead": "79696336a6cfd4ee3fd533cc28ebd87dd748ad41",
85
85
  "files": [
86
86
  "dist",
87
87
  "types",