Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Worker is not working as expected in react typescript #208

Open
chetanshinde118 opened this issue Mar 8, 2021 · 0 comments
Open

Comments

@chetanshinde118
Copy link

chetanshinde118 commented Mar 8, 2021

Below is the error which I received.
TypeError: Failed to register a ServiceWorker for scope ('http://localhost:9000/') with script ('http://localhost:9000/serviceWorker.js'): A bad HTTP response code (404) was received when fetching the script.

Below are the script added in index.html and serviceWorker.js is added at same location.
for now I kept serviceWorker.js empty
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('serviceWorker.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>

@chetanshinde118 chetanshinde118 changed the title Server Worker is not working as expected in react typescript Service Worker is not working as expected in react typescript Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant