From 6f05725dd71d00ca8f9367ec2ea77847cfa3e1c7 Mon Sep 17 00:00:00 2001 From: Ou Date: Thu, 24 Oct 2024 21:18:40 +0800 Subject: [PATCH] fix: add /api in pwa navigateFallbackDenylist --- vite.config.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index d7f1166..28513d4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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 = { +const pwaOption: Partial = { includeAssets: ["icon.svg", "apple-touch-icon.png"], manifest: { name: "NewsNow", @@ -47,6 +47,9 @@ const _pwaOption: Partial = { }, ], }, + 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), ], })