ssrContext and cookies set from server side



  • Hello everybody,

    I’ve been working on my app and I have a question about the ssrContext in quasar.

    The context:

    I’m using Quasar SSR (isomorphic mode) to communicate with a BFF build on my own.
    After login (by using a fetch request with credential=include, mode=cors), my BFF set cross site server side cookies (with httpOnly=true, secure=true and SameSite=None).

    The problem:

    When I use the client side (created or mounted), everything work fine,
    I receive the cookies back from the server and they got store so that cookies are include in the next request to the server.

    But when I’m using the server side (preFetch), according to this

    There is a good reason for this. In a client-only app, every user will be using a fresh instance of the app in their browser. For server-side rendering we want the same thing. Each request should have a fresh, isolated app instance so that there is no cross-request state pollution
    

    So what I understand is that I’m on a fresh instance, so probably a fresh request as well
    (which means a different one from the client side).
    Thus, when I send a request from the ssrContex (preFetch), since it’s a fresh instance, my BFF must also set cookie for the ssrContext right ?

    Well, although I send a request from the ssrContext (via ssrContext.req), it looks like no cookie get set in ssrContext.res, causing my next request to be sent without any cookie.
    Is that an excepted behavior ? If yes why can’t we set cookies when a request is sent from ssrContext ?

    Regards,


Log in to reply