mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-09 15:04:10 +02:00
* service-worker.js fix for issue #1009 fixup * remove weird comment
This commit is contained in:
@ -3,7 +3,11 @@ const CACHE_VERSION = 1
|
|||||||
const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-`
|
const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-`
|
||||||
|
|
||||||
const getApiKey = request => {
|
const getApiKey = request => {
|
||||||
return request.headers.get('X-Api-Key') || 'none'
|
let api_key = request.headers.get('X-Api-Key')
|
||||||
|
if (!api_key || api_key == 'undefined') {
|
||||||
|
api_key = 'no_api_key'
|
||||||
|
}
|
||||||
|
return api_key
|
||||||
}
|
}
|
||||||
|
|
||||||
// on activation we clean up the previously registered service workers
|
// on activation we clean up the previously registered service workers
|
||||||
@ -26,8 +30,10 @@ self.addEventListener('activate', evt =>
|
|||||||
// If no response is found, it populates the runtime cache with the response
|
// If no response is found, it populates the runtime cache with the response
|
||||||
// from the network before returning it to the page.
|
// from the network before returning it to the page.
|
||||||
self.addEventListener('fetch', event => {
|
self.addEventListener('fetch', event => {
|
||||||
// Skip cross-origin requests, like those for Google Analytics.
|
|
||||||
if (
|
if (
|
||||||
|
!event.request.url.startsWith(
|
||||||
|
self.location.origin + '/api/v1/payments/sse'
|
||||||
|
) &&
|
||||||
event.request.url.startsWith(self.location.origin) &&
|
event.request.url.startsWith(self.location.origin) &&
|
||||||
event.request.method == 'GET'
|
event.request.method == 'GET'
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user