@rauchg@leeerob Exactly. The service worker cannot access `process.env`, so how do I pass those values to the worker once it's registered? My initial question was: can the `public/service-worer.js` file be statically built to just contain those values?
@rauchg Regarding `_app.js`, wondering if I could pass my environment variables (which the app proper knows about) to my service worker when it's first initialized? Clearly, I've never setup a service worker before!
@swkeever@rauchg@leeerob This is where I’m having trouble. Firebase’s docs seem to suggest I intercept the message in the background and re-present it using the `self.showNotification(title, options)` browser API which doesn’t seem to accept a link/url argument? What am I missing?
@rauchg@leeerob I'm just realizing now that the main reason I'm using a service worker is to field push notifications in the background. That makes me think `service-worker.js` will need a static copy of my env variables, and probably can't rely on dynamic communication from the main app?
Re-worked type narrowing in TypeScript 4.2 seems like a huge upgrade. Feels like it also has a better sense for how to infer whether a return type can be undefined? Second example feels really nice and I would imagine helps a lot in API documentation/code-hinting. https://t.co/ZyNLJsCbjw
@rauchg@leeerob Ok, now I’m thinking maybe the app passes the env vars to the worker which are then persisted via IndexedDB? Might more trouble than it’s worth but am going to give it a try!
@swkeever@rauchg@leeerob Totally. Blown away by how flaky the whole stack seems. That said, I did finally figure out a way to pass config args to the service worker via url params. Making progress but not thrilled. Still don’t know how to handle a user clicking the notification!
@leeerob@rauchg Yep, that's the example I'm using! Seems like you can't pass data when installing a service worker, but can do so right after? This SO solution is interesting—could use encodeURIComponent to embed JSON in the service worker path? https://t.co/Ag1znw2twi