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

fix: use setupServer to support Next.js #5

Merged
merged 3 commits into from Jun 20, 2022

Conversation

homerchen19
Copy link
Contributor

@homerchen19 homerchen19 commented Jun 15, 2022

  • I added the following code to the template in order to support SSR with Next.js
if (typeof window === 'undefined') {
  const { setupServer } = require('msw/node');
  const server = setupServer(...handlers);
  server.listen();
} else {
  const worker = setupWorker(...handlers);
  worker.start();
}
  • It's pretty much the same as the example from Next.js
  • Updated the version of faker.js and regenerated mock.js in /example

@zoubingwu zoubingwu merged commit 3ce76c3 into zoubingwu:master Jun 20, 2022
@zoubingwu
Copy link
Owner

LGTM, thanks for your contribution!

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

Successfully merging this pull request may close these issues.

None yet

2 participants