Skip to content

Commit

Permalink
scope BASE_URL from .env
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Oct 6, 2024
1 parent 795aebd commit 3ed3d5a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ function App() {
const token = keycloak.token ? keycloak.token : stored_token;

if (navigator.serviceWorker.controller) {
console.log("post message", navigator.serviceWorker);

navigator.serviceWorker.controller.postMessage({
type: "SET_TOKEN",
token: token,
});
}

useEffect(() => {
if (keycloak.authenticated) {
localStorage.setItem("refreshToken", keycloak.refreshToken);
Expand Down
10 changes: 6 additions & 4 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ const router = createBrowserRouter(
{ basename: "/search" }
);

console.log(import.meta.env.BASE_URL);

const base_url = import.meta.env.PROD ? "/search/worker.js" : "/worker.js";
const scope_url = import.meta.env.PROD
? "https://spectra-dev.adma.ai/search/"
: "http://localhost:5173/search/";
// const scope_url = import.meta.env.PROD
// ? "https://spectra-dev.adma.ai/search/"
// : "http://localhost:5173/search/";

if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register(base_url, { scope: scope_url })
.register(base_url, { scope: `${import.meta.env.BASE_URL}` })
.then((registration) => {
console.log(
"Service Worker registered with scope: ",
Expand Down
19 changes: 0 additions & 19 deletions utils/base64.js

This file was deleted.

0 comments on commit 3ed3d5a

Please sign in to comment.