Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service worker issue #267

Open
bart-sofomo opened this issue Sep 16, 2024 · 0 comments
Open

Service worker issue #267

bart-sofomo opened this issue Sep 16, 2024 · 0 comments

Comments

@bart-sofomo
Copy link

Hello,
I'm using https://serwist.pages.dev/ for service worker where I have a code like this:

const firebaseApp = initializeApp({
  apiKey: env.NEXT_PUBLIC_FIREBASE_API_KEY,
  authDomain: env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
  projectId: env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
  storageBucket: env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
  appId: env.NEXT_PUBLIC_FIREBASE_APP_ID,
});

The problem is that it seems like bundling a service worker is a really specific case and somehow when I use env. instead of process.env the browser is claiming invalid variables for those that are used in server side. What I think is happening is service worker when importing env tries to access server side variables which are not available during build time (skipValidation: true on build).

Is there any way to fix this or should I simply not import env in service worker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant