redwood icon indicating copy to clipboard operation
redwood copied to clipboard

feat(rsc-auth): Implement serverStore to hold and pass req info to RSC

Open dac09 opened this issue 9 months ago • 1 comments

First pass at implementing a per-request store that allows:

  • access to headers and cookies from requests in server components
  • access to serverAuthState from server components
  • maps serverAuthState updated from middleware to the the per request store

This PR also implements execution of middleware in the RSC handler. Note that this is done in a "good enough" way currently, because the RSC handler doesn't use Fetch requests (but everything else does)

Important things to note:

  • the store is initialised again in the RSC worker, with the same values on each invocation of renderRsc
  • we have not tested or tried in Dev because rw dev does not work in RSC yet
  • we have not tested behaviour on initial SSR - because this is not implemented yet in RSC

dac09 avatar May 16 '24 08:05 dac09

Pulling out of draft @dthyresson - we still need to check with K6 or curl though if the store is isolated per request!

dac09 avatar May 17 '24 11:05 dac09