Skip to content
Discussion options

You must be logged in to vote

It seems the default payload.login function sets cookies via context.headers['Set-Cookie'], but this is not passed through to the custom resolver.

So to solve this, I had to set them again within the custom resolver like so:

if (loginResult.token) {
    const cookie = generatePayloadCookie({
      collectionAuthConfig: userCollection.config.auth,
      cookiePrefix: context.req.payload.config.cookiePrefix,
      token: loginResult.token,
    });

    context.headers['Set-Cookie'] = cookie;

    if (userCollection.config.auth.removeTokenFromResponses) {
      delete loginResult.token;
    }
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ma-Kas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant