fix: add /api in pwa navigateFallbackDenylist

This commit is contained in:
Ou 2024-10-24 21:18:40 +08:00
parent 2e0f332288
commit 6f05725dd7

View File

@ -8,14 +8,14 @@ import tsconfigPath from "vite-tsconfig-paths"
import unocss from "unocss/vite"
import dotenv from "dotenv"
import type { VitePWAOptions } from "vite-plugin-pwa"
// import { VitePWA } from "vite-plugin-pwa"
import { VitePWA } from "vite-plugin-pwa"
import { projectDir } from "./shared/dir"
dotenv.config({
path: join(projectDir, ".env.server"),
})
const _pwaOption: Partial<VitePWAOptions> = {
const pwaOption: Partial<VitePWAOptions> = {
includeAssets: ["icon.svg", "apple-touch-icon.png"],
manifest: {
name: "NewsNow",
@ -47,6 +47,9 @@ const _pwaOption: Partial<VitePWAOptions> = {
},
],
},
workbox: {
navigateFallbackDenylist: [/^\/api/],
},
devOptions: {
enabled: process.env.SW_DEV === "true",
type: "module",
@ -106,7 +109,7 @@ export default defineConfig({
}),
unocss(),
react(),
// VitePWA(pwaOption),
VitePWA(pwaOption),
nitro(nitroOption),
],
})