added comments

This commit is contained in:
Altair-sh
2026-09-04 19:36:12 +02:00
parent 95880ca080
commit 0ecac6533c
17 changed files with 68 additions and 29 deletions
+4 -4
View File
@@ -38,8 +38,8 @@ export async function redirectRequest(
})
}
/// Browsers send OPTIONS request sometimes to check webserver allowed headers and methods.
/// My backend doesn't support such requests so use proxy to answer to it that all headers and methods are allowed
/// Browsers send OPTIONS request sometimes to check webserver's allowed headers and methods.
/// My C# backend doesn't support OPTIONS, so the proxy answer to OPTIONS request that all headers and methods are allowed.
export async function responseToOPTIONS(req: NextRequest): Promise<NextResponse> {
// console.log('proxy responding to CORS OPTIONS', req.url)
@@ -48,8 +48,8 @@ export async function responseToOPTIONS(req: NextRequest): Promise<NextResponse>
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, PATCH, DELETE, HEAD',
'Access-Control-Allow-Headers':
req.headers.get('access-control-request-headers') || 'Content-Type, Authorization',
'Access-Control-Allow-Headers': '*',
// req.headers.get('access-control-request-headers') || 'Content-Type, Authorization'
},
})
}
+2
View File
@@ -1,3 +1,5 @@
// Directories in src/api/proxy/ are routes.
// Their paths are stored here to simplify refactoring.
export const PROXY_PATHS = {
saveParserBackend: '/api/proxy/saveParserBackend',
}
@@ -4,10 +4,12 @@ import { redirectRequest, responseToOPTIONS as respondToOPTIONS } from '@/app/ap
import { PROXY_PATHS } from '@/app/api/proxy/paths'
import { appConfig } from '@/lib/configLoader'
// Forwards the incoming request to the save parser backend.
async function redirect(req: NextRequest): Promise<NextResponse> {
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