inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
414 stars 41 forks source link

Next.js `basePath` breaks registration #321

Open jpwilliams opened 1 year ago

jpwilliams commented 1 year ago

Describe the bug

When using basePath in a next.config.js file, the "inngest/next" serve handler doesn't detect the correct URL.

To Reproduce

  1. Add basePath: "/example" to examples/framework-nextjs/next.config.js
  2. Run pnpm run dev:example --example framework-nextjs
  3. Run npx inngest-cli@latest dev
  4. In the dev server UI, add http://localhost:3000/example/api/inngest

Expected behavior

The app should correctly register, but instead fails.

The reported URL from the app is still http://localhost:3000/api/inngest (missing the /example prefix), so the dev server also erroneously displays both that and the prefixed URL.

It looks as though Next.js gives us little

Code snippets / Logs / Screenshots

[inngest] reporting URL as: {
  href: 'http://localhost:3000/api/inngest',
  __NEXT_ROUTER_BASEPATH: undefined,
  __NEXT_MANUAL_CLIENT_BASE_PATH: undefined
}

image

System info:

System:
  OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
  CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600K
  Memory: 10.87 GB / 15.53 GB
  Container: Yes
  Shell: 5.0.17 - /bin/bash
Binaries:
  Node: 18.12.1 - ~/.volta/tools/image/node/18.12.1/bin/node
  Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
  npm: 9.6.4 - ~/.volta/tools/image/npm/9.6.4/bin/npm