How to configure a proxy for Vitest #5637
-
|
Hi, My When running vite, this works: When running vitest to test the component above, it's trying to req '/api' and of course failing. I've tried adding the same with no luck. Any help appreciated, thanks! EDIT: The error I'm getting in vitest is |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Hi, I came here because of the new browser mode. or my requests still do not seem to go through. |
Beta Was this translation helpful? Give feedback.
fetch("/api")is meant to run on browser where url origin is automatically inferred, so it's not possible on NodeJS andserver.proxyis not meant to work on Vitest.You probably need to go with mocking fetch during tests.