send over https
This commit is contained in:
parent
d40f98f5e4
commit
4caf1add26
@ -74,7 +74,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function subscribeUser(registration) {
|
function subscribeUser(registration) {
|
||||||
const baseUrl = '{{ config.BASE_URL }}'.replace(/\/$/, ""); // Remove trailing slash if present
|
let baseUrl = '{{ config.BASE_URL }}'.replace(/\/$/, ""); // Remove trailing slash if present
|
||||||
|
if (window.location.protocol === 'https:') {
|
||||||
|
baseUrl = baseUrl.replace(/^http:/, 'https:');
|
||||||
|
}
|
||||||
fetch(`${baseUrl}/vapid-public-key`)
|
fetch(`${baseUrl}/vapid-public-key`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -88,11 +91,16 @@
|
|||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
console.log('Failed to subscribe the user: ', err);
|
console.log('Failed to subscribe the user: ', err);
|
||||||
});
|
});
|
||||||
|
}).catch(function(err) {
|
||||||
|
console.error('Failed to fetch vapid key:', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSubscription(subscription) {
|
function saveSubscription(subscription) {
|
||||||
const baseUrl = '{{ config.BASE_URL }}'.replace(/\/$/, ""); // Remove trailing slash if present
|
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`, {
|
fetch(`${baseUrl}/save-subscription`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user