astro: Always show 404 page on all pages except root

All links no longer work After clicking on any link if developer console closed I see a 404 page, if open noting happens

My config

AstroPWA({
  mode: 'development',
  base: '/',
  scope: '/',
  registerType: 'autoUpdate',
  manifest,
  includeAssets: ['**/favicons/*.{png,svg,ico,xml}'],
  workbox: {
    navigateFallback: '/404',
    globPatterns: ['**/*.{css,js,html,svg,png,ico,txt}'],
  },
  devOptions: {
    enabled: true,
    navigateFallbackAllowlist: [/^\/404$/],
  },
}),

Click on /help/ link image

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

@Clarkkkk if you set the fallback to null, offline will not work.

I’ll try to add similar patch to this added to Vitepress integration ( when I have time ): https://github.com/vite-pwa/vitepress/pull/23/files#diff-616b1f25a229de030f09926b82dafdc6aa0c93a00bd851f2b1f41796570fd629

If change config to navigateFallback: null and remove html from globPatterns

I get the error “Uncaught (in promise) non-precached-url: createHandlerBoundToURL(‘/’) was called, but that URL is not precached. Please pass in a URL that is precached instead.” and stay on the same page.

But it works when developer console is closed

image