How to configure a proxy for Vitest #5637
Answered
by
hi-ogawa
mistercoffee66
asked this question in
Q&A
-
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.
Answered by
hi-ogawa
Apr 30, 2024
Replies: 1 comment 5 replies
-
|
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
mistercoffee66
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.