Compare commits

..

No commits in common. "c9329a33ea2a901b5cc45d2f82d53f4b9c7dc991" and "b446b00fc6976958567ab8ff4c5376de9762596d" have entirely different histories.

3 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion] [tool.bumpversion]
current_version = "1.3.27" current_version = "1.3.26"
commit = true commit = true
tag = true tag = true
tag_name = "{new_version}" tag_name = "{new_version}"

View File

@ -1 +1 @@
1.3.27 1.3.26

View File

@ -74,13 +74,12 @@
} }
function subscribeUser(registration) { function subscribeUser(registration) {
fetch('/vapid-public-key') let baseUrl = '{{ config.BASE_URL }}'.replace(/\/$/, ""); // Remove trailing slash if present
.then(response => { if (window.location.protocol === 'https:') {
if (!response.ok) { baseUrl = baseUrl.replace(/^http:/, 'https:');
throw new Error('Failed to fetch VAPID public key');
} }
return response.json(); fetch(`${baseUrl}/vapid-public-key`)
}) .then(response => response.json())
.then(data => { .then(data => {
const applicationServerKey = urlB64ToUint8Array(data.public_key); const applicationServerKey = urlB64ToUint8Array(data.public_key);
registration.pushManager.subscribe({ registration.pushManager.subscribe({
@ -93,12 +92,16 @@
console.log('Failed to subscribe the user: ', err); console.log('Failed to subscribe the user: ', err);
}); });
}).catch(function(err) { }).catch(function(err) {
console.error('Error during subscription process:', err); console.error('Failed to fetch vapid key:', err);
}); });
} }
function saveSubscription(subscription) { function saveSubscription(subscription) {
fetch('/save-subscription', { let baseUrl = '{{ config.BASE_URL }}'.replace(/\/$/, ""); // Remove trailing slash if present
if (window.location.protocol === 'https:') {
baseUrl = baseUrl.replace(/^http:/, 'https:');
}
fetch(`${baseUrl}/save-subscription`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',