next-pwa icon indicating copy to clipboard operation
next-pwa copied to clipboard

Offline route change throw error caused by _middleware

Open wztech0192 opened this issue 2 years ago • 0 comments

Summary

When running in offline mode, change route using next/link throw 'Uncaught (in promise) TypeError: Failed to fetch' from

fetch(r, {
       method: "HEAD",
       credentials: "same-origin",
       headers: {
    "x-middleware-preflight": "1"
}

It works when remove _middleware.ts in the pages folder. It also work when change route through browser url.

my next-config.js

  pwa: {
    dest: 'public',
    register: false,
    cacheOnFrontEndNav: true,
    disable: process.env.NODE_ENV === 'development',
    publicExcludes: [
      '!images/**/*',
      '!locales/**/*',
      '!android-chrome-512x512.png',
      '!android-chrome-192x192.png',
      '!logo-bridges-orange.png',
    ],
    buildExcludes: [
      /^(build-manifest\.json|react-loadable-manifest\.json|server\/middleware-manifest\.json|server\/middleware-runtime\.js|_middleware\.js|server\/pages\/_middleware\.js)$/,
    ],
  },

Versions

  • next-pwa: 5.5.2
  • next: 12.1.0

How To Reproduce

add _middleware.ts/js to pages folder. Start navigate using next/link in offline mode.

wztech0192 avatar May 14 '22 05:05 wztech0192