How to mock better-auth with MSW?
I tried to use MSW to mock the (GitHub) OAuth flow. However, I have been unsuccessful in getting the session on the server.
Here is a minimal reproduction:
https://codesandbox.io/p/devbox/better-auth-with-msw-5dy86g
Please test on a new browser tab:
https://5dy86g-3000.csb.app/
Steps to reproduce:
Here is a minimal reproduction:
https://codesandbox.io/p/devbox/better-auth-with-msw-5dy86g
Please test on a new browser tab:
https://5dy86g-3000.csb.app/
Steps to reproduce:
- Run the server
MOCK_SERVER=true pnpm dev(if the server is running at first, please restart it with this command) - Go to https://5dy86g-3000.csb.app/
- Click "Sign In"
- Copy the
statein the URL. E.g.,&state=XXX, copy the XXX - Go to https://5dy86g-3000.csb.app/api/auth/callback/github?code=mock_github_code&state=XXX directly, paste your state at the end
- OAuth flow is done.
- If you're getting an
invalid_codeerror, please try to fork the codesandbox and test with your own csb terminal. instrumentation.tsonly runs whenpnpm dev, if any changes are made ininstrumentation.ts, please restart the next-server.
