chore(cookies): debug (revert this)
This commit is contained in:
@@ -32,4 +32,36 @@ export const userRouter = createTRPCRouter({
|
||||
|
||||
return updatedUser;
|
||||
}),
|
||||
debugPostCookie: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
sameSite: z.enum(['lax', 'strict', 'none']),
|
||||
domain: z.string(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
ctx.setCookie('debugCookie', new Date().toISOString(), {
|
||||
domain: input.domain,
|
||||
sameSite: input.sameSite,
|
||||
httpOnly: true,
|
||||
secure: true,
|
||||
path: '/',
|
||||
});
|
||||
}),
|
||||
debugGetCookie: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
sameSite: z.enum(['lax', 'strict', 'none']),
|
||||
domain: z.string(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
ctx.setCookie('debugCookie', new Date().toISOString(), {
|
||||
domain: input.domain,
|
||||
sameSite: input.sameSite,
|
||||
httpOnly: true,
|
||||
secure: true,
|
||||
path: '/',
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -15,14 +15,7 @@ export function createContext({ req, res }: CreateFastifyContextOptions) {
|
||||
session: getAuth(req),
|
||||
// we do not get types for `setCookie` from fastify
|
||||
// so define it here and be safe in routers
|
||||
setCookie: (
|
||||
key: string,
|
||||
value: string,
|
||||
options: {
|
||||
maxAge: number;
|
||||
path: string;
|
||||
},
|
||||
) => {
|
||||
setCookie: (key: string, value: string, options: any) => {
|
||||
// @ts-ignore
|
||||
res.setCookie(key, value, options);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user