Axios or $fetch in api routes?
I'm starting a new project which requires authentication to an external backend endpoint.
This is how I visualise the flow
The reason I need to make the initial request to api route is because the session is stored in the server cookie.
This is how I visualise the flow
- use $fetch('/api/auth/login') on client side to pass data to server api
- server api accepts the body and pass it to $fetch / axios and sends POST req to external endpoints
- external endpoint returns response.
- api route returns status and response to client
- client side process the response to show success/ error response.
The reason I need to make the initial request to api route is because the session is stored in the server cookie.