Skip to content

Clarification in documentation on setting cookies #77

Answered by jweatherby
jweatherby asked this question in Q&A
Discussion options

You must be logged in to vote

Update: I was able to figure this out with the following:

// hooks.server.ts

const trpcHandle = createTRPCHandle({
  router, createContext, responseMeta: (ctx) => {
    const { data: [{ error, result }], paths } = ctx
    let headers
    if (paths?.includes('account.login') && !error) {
      headers = {
        'Set-Cookie': buildCookie(/* ...result.data */)
      }
    }
    return { headers }
  }
});

Not sure if this is the best approach, but it does the trick.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by icflorescu
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