Skip to content

Commit

Permalink
bug fix: properly set cookie opts for auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkernel committed Jun 10, 2022
1 parent d32407e commit 4575de1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/auth/src/routes/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SERVICE_POLICY = {
}

const LOCAL = process.env.ENV === 'DEV'
const DOMAIN = LOCAL ? 'localhost:3003' : 'kernel.community'
const DOMAIN = LOCAL ? '.app.localhost' : 'kernel.community'

const register = async (server, rpcPath, { seed, authMemberId, rpcEndpoint }) => {

Expand Down Expand Up @@ -63,17 +63,20 @@ const register = async (server, rpcPath, { seed, authMemberId, rpcEndpoint }) =>
const { authPayload, jwt, persist } = await rpcService.call(service, fn, params)
if (persist) {
// TODO: set expires, set env properly
reply.setCookie('stagingJWT', jwt, {
//domain: DOMAIN,
const opts = {
domain: DOMAIN,
maxAge: 60 * 60 * 24,
//sameSite: 'none',
sameSite: 'none',
secure: true,
httpOnly: true,
path: '/'
})
}
reply.setCookie('stagingJWT', jwt, opts)
reply.setCookie('stagingUser', JSON.stringify(authPayload), {
//domain: DOMAIN,
domain: DOMAIN,
maxAge: 60 * 60 * 24,
//sameSite: 'none',
secure: true,
sameSite: 'none',
path: '/'
})
}
Expand Down

0 comments on commit 4575de1

Please sign in to comment.