Hi, I have a PWA application with push notification functionality. I am still new to this and have just recently added the push functionality into my app. I am referring to
Get started with Progressive Web Apps - Microsoft Edge Development | Microsoft Docs[
^] for my learning step.
I tried to run the app in Chrome and i encountered the error as same as title above in F12 development tools. Full error is as below:
POST http:
.
I have install the web-push library as guided by the link above and have the following codes in the index.js file provided by the library installed:
router.post('/register', function (req, res) {
res.sendStatus(201);
});
At first i thought the codes in above link only support Edge but i do not think this is the case here as the following codes is executed after a promise is returned:
navigator.serviceWorker.ready
.then(function (registration) {
}).then(function (subscription) {
fetch('./register', {
method: 'post',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({
subscription: subscription
}),
});
What I have tried:
1. Change the script by referring to another source but to no avail.
2. Search online for error 405 solution seems to be permission issue but could not pinpoint a root cause here.
3. Thought is path issue but in fetch('./register') but this is not the case.