How to create custom $fetch for server side only
Hi all!
I'm trying to think of way to create custom $fetch function to include authorization header for JWT token. JWT token is obtained from another backend API that I have.
Currently I'm storing the JWT token in server side of nuxt app and only exposes session id to the client side of nuxt app through cookie. When I'm making a request from server side of nuxt app to my other backend API, I want to include this JWT token that i stored in the session (sqlite db).
I've seen some examples that used nuxt plugin to define custom $fetch during vue app initialization but I wasn't sure how to achieve this only for server side $fetch (it has to be server side because that's where i store the jwt token).
I'm trying to think of way to create custom $fetch function to include authorization header for JWT token. JWT token is obtained from another backend API that I have.
Currently I'm storing the JWT token in server side of nuxt app and only exposes session id to the client side of nuxt app through cookie. When I'm making a request from server side of nuxt app to my other backend API, I want to include this JWT token that i stored in the session (sqlite db).
I've seen some examples that used nuxt plugin to define custom $fetch during vue app initialization but I wasn't sure how to achieve this only for server side $fetch (it has to be server side because that's where i store the jwt token).