From c25e15e6972d0828d14e8b607a091202cf85cb25 Mon Sep 17 00:00:00 2001 From: Cosmo Date: Thu, 23 Apr 2026 08:11:16 +0000 Subject: [PATCH] fix(transport): accept ORGP self-signed cert via undici Agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/api/transport/route.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/api/transport/route.ts b/app/api/transport/route.ts index daf708d..6d7797f 100644 --- a/app/api/transport/route.ts +++ b/app/api/transport/route.ts @@ -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, } )