This is my firebase-messaging-sw.js file. What i require is to fetch environment variables from my .env file. Either directly or indirectly. I have tried other answers available here but to no avail. I am using React boilerplate and those answers just don't match up for me. Is there a way i could fetch these? Any help would be appreciated.
Code right now:
importScripts(`https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js`)
importScripts(`https://www.gstatic.com/firebasejs/7.17.1/firebase-messaging.js`)
firebase.initializeApp({
apiKey: `AIz.....Cvg5E_Q`,
authDomain: `example.firebaseapp.com`,
databaseURL: `https://example.firebaseio.com`,
projectId: `projectid`,
storageBucket: `example.com`,
messagingSenderId: `1...7`,
appId: `1..............30`,
})
Preferred way is to have it access from .env or some variable. By either importing or whatever. P.s Imports and require don't work in this service worker.
importScripts(`https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js`)
importScripts(`https://www.gstatic.com/firebasejs/7.17.1/firebase-messaging.js`)
firebase.initializeApp(firebaseConfig)