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: 1 comment 5 replies
-
|
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.proxy
is not meant to work on Vitest.You probably need to go with mocking fetch during tests.