IcyFoxer
Explore posts from serversAxios 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
1. use $fetch('/api/auth/login') on client side to pass data to server api
2. server api accepts the body and pass it to $fetch / axios and sends POST req to external endpoints
3. external endpoint returns response.
4. api route returns status and response to client
5. client side process the response to show success/ error response.
Is this the right way to make an authentication req to external endpoints?
The reason I need to make the initial request to api route is because the session is stored in the server cookie.
1 replies