Files
supabase/apps/studio/pages/api/content/graphql.ts
T
2026-04-21 19:48:47 +08:00

25 lines
782 B
TypeScript

import { NextApiRequest, NextApiResponse } from 'next'
const CONTENT_API_URL = process.env.NEXT_PUBLIC_CONTENT_API_URL!
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== 'POST') {
res.setHeader('Allow', ['POST'])
return res.status(405).json({ error: `Method ${req.method} Not Allowed` })
}
try {
const response = await fetch(CONTENT_API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(req.body),
})
const data = await response.json()
return res.status(response.status).json(data)
} catch (error) {
console.error('Content API proxy error:', error)
return res.status(500).json({ error: 'Failed to reach Content API' })
}
}