import type { NextRequest } from 'next/server' import { NextResponse } from 'next/server' import { redirectRequest, respondToOPTIONS } from '@/app/api/proxy/functions' import { PROXY_PATHS } from '@/app/api/proxy/paths' import { appConfig } from '@/lib/configLoader' //TODO: remove this proxy once the backend handles CORS itself. It only exists // so the browser can make same-origin requests; with CORS on the backend the // client can call it directly and this extra hop disappears. // Forwards the incoming request to the save parser backend. async function redirect(req: NextRequest): Promise { return await redirectRequest( req, PROXY_PATHS.saveParserBackend, appConfig.services.saveParserBackend.url ) } // handlers for each request method on this route export const GET = redirect export const POST = redirect export const PUT = redirect export const PATCH = redirect export const DELETE = redirect export const HEAD = redirect export const OPTIONS = respondToOPTIONS