fix(transport): accept ORGP self-signed cert via undici Agent
Some checks failed
Deploy / deploy (push) Failing after 1m20s
Some checks failed
Deploy / deploy (push) Failing after 1m20s
ORGP SPb uses a TLS chain Node rejects by default (curl works with -k but Node fetch doesnt). Use an undici Agent with rejectUnauthorized false for this one hop. Also drop the conflicting next.revalidate: 0 option — cache: no-store already covers it.
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
export const dynamic = 'force-dynamic'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { Agent } from 'undici'
|
||||
|
||||
const ORGP_BASE = 'https://transport.orgp.spb.ru'
|
||||
|
||||
// ORGP TLS chain fails default verification in Node — match curl -k behaviour.
|
||||
const insecureAgent = new Agent({ connect: { rejectUnauthorized: false } })
|
||||
|
||||
export async function GET(req: Request) {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const stopId = searchParams.get('stopId')
|
||||
@@ -31,8 +35,8 @@ export async function GET(req: Request) {
|
||||
},
|
||||
body: body.toString(),
|
||||
cache: 'no-store',
|
||||
// @ts-ignore next-internal option for timeout
|
||||
next: { revalidate: 0 },
|
||||
// @ts-ignore — undici dispatcher option at runtime
|
||||
dispatcher: insecureAgent,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user