How to refresh and pass a token with every request whether server side or client side in sveltekit

Viewed 262

I am building a simple app where users can read blogs written by authors. These blogs are fetched from an express backend that implements HMAC authentication. Every client app gets an appID and appSecret. Using this secret, the client creates a signature for every request and sends it in the Auth header.

Now, I am trying to figure out what is the correct method to add this Auth header with every request whether server-side or client-side. This works when I do fetch client-side in onMount, but the Auth header is missing for requests that originate from the load method in SSR.

Is this related to the below issue?

https://github.com/sveltejs/kit/issues/696

If yes, is there a workaround? Because this is a blocker for me.

All my load methods route requests through a common api.js module. I have tried modifying the header in api.js, in handle hooks but no success.

0 Answers
Related