Register a service worker within a custom block


I’d like to be able to register a remotely hosted service worker within a custom block in order to activate push notifications. I tried it but I faced cross-origin errors because the iframe is on a different origin from the remote service worker. Any ideas how I could achieve this?

Thanks in advance,

The going advice is to use importScripts to load cross-origin scripts from the Service Worker:

Unfortunately, this isn’t a complete answer. You’ll still need a way to host a standalone script (that is: the “bootstap” Service Worker script that you register via navigator.serviceWorker.register) in a Block installation, and that’s not currently possible.

The good news is that Custom Blocks is still in beta, so the folks at Airtable are especially receptive to feature requests like this.

1 Like

Thanks for the response @Mike_Pennisi. Hopefully its something that could be implemented soon :slight_smile: