Skip to content

Commit

Permalink
Chech if fetch event occurs, correct base_url
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Oct 7, 2024
1 parent 447bf53 commit 55cb95b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ const Main = () => {
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";
const base_url = import.meta.env.PROD
? "/search/serviceWorker.js"
: "/serviceWorker.js";
const scope_url = import.meta.env.PROD
? "https://spectra-dev.adma.ai/search/"
: "http://localhost:5173/search/";

const registerServiceWorker = async () => {
if ("serviceWorker" in navigator) {
try {
const registration = await navigator.serviceWorker.register(
"/serviceWorker.js",
{ scope: scope_url }
);
const registration = await navigator.serviceWorker.register(base_url, {
scope: scope_url,
});
console.log("scope", registration.scope);

await registration.active.postMessage({
Expand Down

0 comments on commit 55cb95b

Please sign in to comment.