fixed warnings from eslint
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
/// Resend request to backend.
|
||||
/// Body is being sent as stream.
|
||||
/**
|
||||
* Resend request to backend.
|
||||
* Body is being sent as stream.
|
||||
*/
|
||||
export async function redirectRequest(
|
||||
req: NextRequest,
|
||||
proxyUrl: string,
|
||||
@@ -26,8 +28,7 @@ export async function redirectRequest(
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
body: req.body,
|
||||
// @ts-ignore
|
||||
duplex: 'half', // some property required by nodejs but not defined in @types/node
|
||||
duplex: 'half', // required by nodejs when the body is a stream, see src/types/fetch.d.ts
|
||||
})
|
||||
|
||||
return new NextResponse(backendRes.body, {
|
||||
@@ -41,9 +42,14 @@ export async function redirectRequest(
|
||||
})
|
||||
}
|
||||
|
||||
/// 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(
|
||||
/**
|
||||
* 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 respondToOPTIONS(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- required by the nextjs route handler signature
|
||||
req: NextRequest
|
||||
): Promise<NextResponse> {
|
||||
// console.log('proxy responding to CORS OPTIONS', req.url)
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import {
|
||||
redirectRequest,
|
||||
responseToOPTIONS as respondToOPTIONS,
|
||||
} from '@/app/api/proxy/functions'
|
||||
import { redirectRequest, respondToOPTIONS } from '@/app/api/proxy/functions'
|
||||
import { PROXY_PATHS } from '@/app/api/proxy/paths'
|
||||
import { appConfig } from '@/lib/configLoader'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user