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