mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
25 lines
782 B
TypeScript
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' })
|
|
}
|
|
}
|