question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service worker returning index page for nonexistent route

See original GitHub issue

Is this a bug report?

Not sure. Trying to determine that.

Which terms did you search for in User Guide?

service worker

Environment

Node v6.9.2 NPM v3.10.9 react-scripts 1.0.14

Mac OSX El Capitan 10.11.6 Google Chrome Version 61.0.3163.100 (Official Build) (64-bit)

Steps to Reproduce

  1. Scaffold a new react application following the instructions found on the user guide.
  2. Serve index.html and all related artifacts in the ./build directory from my server.
  3. Navigate to localhost:8080. Observe that the “Welcome to React” page is displayed.
  4. Navigate to localhost:8080/idonotexist. Observe that the “Welcome to React” page is still displayed.

Expected Behavior

I expected the localhost:8080/idonotexist request to be handled by the server, rather than the service worker.

Actual Behavior

The service worker returns localhost:8080/idonotexist from the service worker. The page that is displayed is the default “Welcome to React” page.

image

Is this the desired behavior of the service worker? My understanding of service workers is limited, so I’m trying to determine if this is a bug or simply a gap in my knowledge.

Thanks for the great tool. Keep up the good work.

Brandon

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
seejamescodecommented, Jan 4, 2018

If anyone is looking for a non-eject solution to this until #3419 is merged, you can use react-app-rewired with this config-overrides.js.

0reactions
stale[bot]commented, Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Service worker returning Offline page instead of 404 page ...
I'm using this service worker for caching and offline mode. when I am already on any existing page of my website and I...
Read more >
Comparing Wayne.js with Express.js for service worker routing
In this article, we will describe how to export a simple REST API from Express.js to Wayne.js for service worker routing.
Read more >
workbox-routing - Chrome Developers
Routes requests in your service worker to specific caching strategies or callback functions.
Read more >
Customizing Service Workers in ReactJS Progressive Web ...
Learn how to customize Google Workbox's default behavior for a service worker in your React app. This articles explains how to modify the ......
Read more >
Using Angular routes in a single-page application
It is possible for a user to try to access a route that you have not defined. To account for this behavior, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found