622737fdca
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { getApiBaseUrl, jsonResponse } from '../../../_lib/api';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
async function getSuperToken(): Promise<string | undefined> {
|
|
const { cookies } = await import('next/headers');
|
|
return (await cookies()).get('tower_super_token')?.value;
|
|
}
|
|
|
|
export async function GET(): Promise<Response> {
|
|
const token = await getSuperToken();
|
|
const res = await fetch(`${getApiBaseUrl()}/admin/orgs`, {
|
|
headers: { Accept: 'application/json', ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
|
cache: 'no-store',
|
|
});
|
|
return jsonResponse(await res.json(), res.status);
|
|
}
|
|
|
|
export async function POST(req: Request): Promise<Response> {
|
|
const token = await getSuperToken();
|
|
const body = await req.json().catch(() => ({}));
|
|
const res = await fetch(`${getApiBaseUrl()}/admin/orgs`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json', ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
|
body: JSON.stringify(body),
|
|
cache: 'no-store',
|
|
});
|
|
return jsonResponse(await res.json(), res.status);
|
|
}
|