Add MAX Mini App frontend flow
This commit is contained in:
27
server/api/auth/max-mini-app/connect.post.ts
Normal file
27
server/api/auth/max-mini-app/connect.post.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig(event);
|
||||
const backendUrl = new URL(config.backendGraphqlUrl);
|
||||
const endpoint = `${backendUrl.origin}/auth/max-mini-app/connect`;
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user