Files
dlearn-front/server/api/auth/login-step-two.post.js
T
2024-05-27 15:13:45 +03:30

24 lines
665 B
JavaScript

export default defineEventHandler(async (event) => {
const body = await readBody(event);
const { public: { apiBase } } = useRuntimeConfig();
try {
const data = await $fetch(`${apiBase}/auth/login-step-two`, {
method: 'POST',
body,
headers: {
'Accept': 'application/json',
}
});
setCookie(event, 'token', data.token, {
httpOnly: true,
secure: true,
maxAge: 60 * 60 * 24 * 7, // 1 week
path: '/'
})
return data;
} catch (err) {
console.log('server err :', err);
return err
}
})