Nuxt3 proxy in server/api/[...].ts
use $fetch to backend api
but response is not json
2 Replies
Hi @Night. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, I don't have enough specific details to fully address your question about proxying non-JSON responses in a Nuxt 3 server API route. However, I can provide some general guidance related to using
$fetch
in Nuxt 3:
1. When using $fetch
in Nuxt 3, it automatically handles JSON responses by default. As mentioned in the Docs > Api > Utils > $fetch, Nuxt uses ofetch to expose the $fetch
helper globally for making HTTP requests.
2. If you're dealing with non-JSON responses, you might need to handle the response manually. Unfortunately, the provided knowledge sources don't contain specific information about handling non-JSON responses with $fetch
in a server API route.
3. You might want to consider using the raw
option of $fetch
to get the raw response, but this is not explicitly mentioned in the given knowledge sources for the server API routes.
4. When working with server API routes in Nuxt 3, you typically use defineEventHandler
as shown in some of the examples. However, the knowledge sources don't provide a specific example of proxying non-JSON responses in this context.
To get a more accurate and detailed answer to your specific situation, you might want to consult the official Nuxt 3 documentation or ask a more specific question about the type of response you're dealing with and what you've tried so far.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1291669794667630633> Kapa.ai is still learning and improving, please let me know how I did by reacting below.