32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { gatewayUrl, withAuthHeaders } from '~/lib/server/gateway';
|
|
|
|
export async function GET({ request }: { request: Request }) {
|
|
try {
|
|
const upstream = await fetch(gatewayUrl('/me/profile-status'), {
|
|
method: 'GET',
|
|
headers: withAuthHeaders(request, { Accept: 'application/json', 'x-portal-target': 'public' }),
|
|
cache: 'no-store',
|
|
});
|
|
|
|
const payload = await upstream.json().catch(() => ({}));
|
|
if (!upstream.ok) {
|
|
return new Response(
|
|
JSON.stringify({
|
|
success: false,
|
|
error: payload?.message || payload?.error || 'Failed to load profile status',
|
|
}),
|
|
{ status: upstream.status, headers: { 'Content-Type': 'application/json' } },
|
|
);
|
|
}
|
|
|
|
return new Response(JSON.stringify({ success: true, data: payload }), {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
} catch (error: any) {
|
|
return new Response(JSON.stringify({ success: false, error: error?.message || 'Internal Server Error' }), {
|
|
status: 500,
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
}
|
|
}
|