blob: db1fbb6c7a676943abb0a2cde27b8166776e4b17 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { post } from '$lib/utils';
import cookie from 'cookie';
let maxAge = 30 * 24 * 60 * 60;
export async function POST({ request }) {
let body = await post('/login', await request.json());
let expires = new Date();
expires.setSeconds(expires.getSeconds() + maxAge);
return {
body,
headers: {
'set-cookie': cookie.serialize('token', body.token, {
httpOnly: true,
maxAge,
sameSite: 'lax',
path: '/',
expires
})
}
};
}
|