diff --git a/src/main.jsx b/src/main.jsx index b632cd2..25c764f 100755 --- a/src/main.jsx +++ b/src/main.jsx @@ -20,10 +20,12 @@ const router = createBrowserRouter( const stored_token = localStorage.getItem("token"); const token = keycloak.token ? keycloak.token : stored_token; +const base_url = import.meta.env.PROD ? "/search/worker.js" : "/worker.js"; + if ("serviceWorker" in navigator) { window.addEventListener("load", () => { navigator.serviceWorker - .register("./worker.js") + .register(base_url) .then((registration) => { console.log( "Service Worker registered with scope: ", diff --git a/vite.config.js b/vite.config.js index 5a33944..9cc50ea 100755 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,7 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], -}) +});