Files
2026-04-04 14:21:31 +07:00

28 lines
841 B
TypeScript

export default defineEventHandler(async (event) => {
const config = useRuntimeConfig(event);
const backendUrl = new URL(config.backendGraphqlUrl);
const endpoint = `${backendUrl.origin}/auth/telegram-mini-app/session`;
const body = await readBody(event);
const cookie = getHeader(event, 'cookie');
const authorization = getHeader(event, 'authorization');
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'content-type': 'application/json',
...(cookie ? { cookie } : {}),
...(authorization ? { authorization } : {}),
},
body: JSON.stringify(body),
});
setResponseStatus(event, response.status);
const contentType = response.headers.get('content-type');
if (contentType) {
setHeader(event, 'content-type', contentType);
}
return await response.json();
});