Set header from server middleware
Hello! I am trying to set the "Authorization" header from server middleware, for an API.
but nothing seems to be working. I am getting 403 forbidden from my API
1 Reply
Hmmm noted. I simply want to add the token with every request automatically, without having to $fetch the token outright every time I want it. The docs say that one of the use cases for server middleware is adding headers so I was going by that.
Thank you! How could I do this on the server side? e.g. from a server/api/xxx
Maybe I need to rethink my approach. My goal is to avoid calling retrieving directly from the kinde api in the client, and instead accessing it through my server, so I can more easily have fine tuned control, and to do that I need to store the token I retrieve, and I would like to avoid retrieving it again and again outright (I want to hide it essentially.) Do you think it could be more reasonable as a series of composables instead?
Awesome, sounds like a plan! Thank you very much for your help, I really appreciate it!