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.

Is there a way to submit edits to the website documentation?

See original GitHub issue

Is your feature request related to a problem? Please describe. When I load my app at a route other than the root, MSW would fail to load the service worker. For example, if I load my app from this URL http://localhost:3000/customers/2dd641c3-4069-424e-ad3d-8b2563358dd8, I get the following error.

[MSW] Failed to register Service Worker (./mockServiceWorker.js). DOMException: Failed to register a ServiceWorker for scope ('http://localhost:3000/customers/') with script ('http://localhost:3000/customers/mockServiceWorker.js'): The script has an unsupported MIME type ('text/html').

I figured out that this is because it was looking for the service worker relative to the initial URL, so I need to change my start method to be absolute.

// old code
return setupWorker(...handlers).start();

// new code
return setupWorker(...handlers).start({
  serviceWorker: {
    url: '/mockServiceWorker.js',
  },
});

Describe the solution you’d like I was thinking to update the custom URL page in the docs to indicate that the default setting is to look for the service mocks at <HOSTNAME>/mockServiceWorker.js but actually it looks for it at <initialURL>/mockServiceWorker.js.

Perhaps I still don’t understand correctly but I believe that is the behavior.

Describe alternatives you’ve considered An alternative would be to update the default to

const DEFAULT_START_OPTIONS: DeepRequired<StartOptions> = {
  serviceWorker: {
    url: '/mockServiceWorker.js', // remove the initial "." on this url value
    options: null as any,
  },
  quiet: false,
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kettanaitocommented, May 11, 2020

@mitchconquer, create a pull request from your fork to this repository, and let’s review it together. These instructions can be helpful to create a pull request from your fork. Looking forward to see your pull request 😃

0reactions
mitchconquercommented, May 11, 2020

Awesome thanks for the guidance! Here’s PR #153.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Website Edit/Edit Request Process | Mechanical Engineering
All content submitted for changes should be in a Word document. In that Word document, the rule is “less is more”—do not overly...
Read more >
Allow users to add and edit documents from the front end
Use Document Library Pro with the Gravity Forms plugin to add a 'Submit document' form to the front end of your website, either...
Read more >
Edit and Create Documentation - Guidelines for Contributing ...
Once you are finished editing the document, describe your changes at the bottom of the document and click Propose File Change. This will...
Read more >
Suggest edits in Google Docs - Computer
Suggest changes to a file. On your computer, open a document at docs.google.com. Select the text you want to change. A button appears...
Read more >
How to Edit & Turn in a Google Document - YouTube
This video shows how to edit and submit a Google Document as part of an assignment on Google Classroom.
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