vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.94k stars 26.87k forks source link

Using custom runtime breaks dynamic routes #56869

Open capJavert opened 1 year ago

capJavert commented 1 year ago

Link to the code that reproduces this issue

https://github.com/capJavert/nextjs-functions-break-dynamic-routes

To Reproduce

  1. Add serverless function with custom runtime (eg. Go) to your Next.js project
  2. Add dynamic API routes to your Next.js app inside app directory (or old school dynamic routes through /api/pages
  3. Deploy to Vercel

You will observe:

I also noticed api routes without dynamic segments work fine /api/boo.

Deployment summary also shows all the functions correctly:

image

Current vs. Expected behavior

When custom runtime is used inside top level /api directory Next.js dynamic routes break and show 404.

Dynamic routes should work as expected.

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 18.16.0
  npm: 9.5.1
  Yarn: 1.22.18
  pnpm: 8.6.3
Relevant Packages:
  next: 13.5.5-canary.16
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Middleware / Edge (API routes, runtime)

Additional context

No response

barisceliker1 commented 11 months ago

I also have the same problem. Did you find anything ?

capJavert commented 11 months ago

Nope, just broken.

yoeven commented 8 months ago

Same issue here, broke an entire prod project and spent hours trying to fix it. Works well locally but not when deployed, one hack that fixed it was using a subdomain with rewrites to the api folder from the next.config.js. However, domains without a rewrite to the API folder breaks

capJavert commented 8 months ago

I can confirm this is still issue in 14.1. But unfortunately like many crucial bugs like this no response still.

capJavert commented 3 months ago

This is still happening in latest release. Any reply/ack?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote šŸ‘ on the issue description or subscribe to the issue for updates. Thanks!