ai icon indicating copy to clipboard operation
ai copied to clipboard

Pathname '/https,http://localhost:63450/api/chat' should have matched '/api/chat' with Next.js 14.0.2

Open AlexIsMaking opened this issue 1 year ago • 4 comments

Description

Pathname '/https,http://localhost:63450/api/chat' should have matched '/api/chat'

error when sending requests to the chat route with Next.js 14.0.2. This can be avoided by downgrading to Next.js 14.0.1.

Steps to reproduce -

  1. Clone the Vercel AI SDK, Next.js, and OpenAI Chat Example
  2. Configure the environment variable, install packages and run with vercel deploy, then submit a prompt - the app will work as expected
  3. Update to latest stable release of Next.js with npm i next@latest
  4. Run with vercel deploy - an error will be logged

⨯ node_modules/next/dist/esm/server/web/edge-route-module-wrapper.js (58:18) @ EdgeRouteModuleWrapper.handler ⨯ Invariant: no match found for request. Pathname '/https,http://localhost:63450/api/chat' should have matched '/api/chat'

AlexIsMaking avatar Nov 14 '23 00:11 AlexIsMaking

@AlexIsMaking Are you using the useChat hook?

tgonzales avatar Nov 14 '23 01:11 tgonzales

@tgonzales yes I am, I haven't changed anything from the example project.

AlexIsMaking avatar Nov 14 '23 01:11 AlexIsMaking

@AlexIsMaking I believe it is related to this issue https://github.com/vercel/next.js/issues/48295 Awaiting

tgonzales avatar Nov 14 '23 09:11 tgonzales

@tgonzales ah, thanks for the heads up. I'll share some info on that issue too.

There are some differences though - I'm not using middleware and Next.js 14.0.1 is working for me, whereas that issue was opened for ~13.3.

AlexIsMaking avatar Nov 14 '23 10:11 AlexIsMaking