Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I access "/notice" to display cached content, it will automatically redirect to "/notice/" by default homepage "/" #740

Closed
kongyijilafumi opened this issue Aug 15, 2024 · 3 comments

Comments

@kongyijilafumi
Copy link

How do I configure PWA

  • When I visit "/notice"
    image
    image

  • When I visit "/notice/", it will redirect to homepage "/"
    image
    image

so,what can i reslove this problem?

@userquin
Copy link
Member

using SSR? if so check vite-pwa/sveltekit#65 and vite-pwa/sveltekit#65 (comment)

@kongyijilafumi
Copy link
Author

using SSR? if so check vite-pwa/sveltekit#65 and vite-pwa/sveltekit#65 (comment)

@userquin
there is my config file

// nuxt.config.ts
  pwa: {
    strategies: 'generateSW',
    registerType: "prompt",
    manifest : {
      name: 'xxx',
      short_name: 'xxx',
    },
    workbox: {
      globPatterns: ['**/*.{js,css,html,png,svg,ico,jpg,mp3}'],
      runtimeCaching: [
        {
          urlPattern: new RegExp(`^http.*\.(js|css|html|png|svg|ico|jpg|mp3)\/?$`),
          handler: "CacheFirst",
          options: {
            cacheName: 'assets-cache',
            expiration: {
              maxEntries: 10,
              maxAgeSeconds: 60 * 60 * 24 * 30, // <== 30 days
            },
            cacheableResponse: {
              statuses: [0, 200],
            },
            matchOptions: {
              ignoreSearch: true,
            },
          },
        }
      ]
    },
    client: {
      installPrompt: true,
      // you don't need to include this: only for testing purposes
      // if enabling periodic sync for update use 1 hour or so (periodicSyncForUpdates: 3600)
      periodicSyncForUpdates: 3600,
    },
    devOptions: {
      enabled: true,
      suppressWarnings: true,
      navigateFallback: '/',
      navigateFallbackAllowlist: [/^\/$/],
      type: 'module',
    },
  }

I use nuxt generate to build static web content, and then I access the /motion/ question as the title suggests. My website is using static content. How can I configure the nuxt.config.ts file to achieve the desired effect?

@kongyijilafumi
Copy link
Author

I resolved this problem.I configuration pwa.workbox.navigateFallbackDenylist.

// nuxt.config.ts
pwa:{
  workbox: {
    navigateFallbackDenylist: [
      /\/$/,
      /\?\w+/,
    ],
  }
}

and then, It will not redirect to homepage "/".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants