NextJS dynamic page with catch all route overrides all API routes
I've run into some trouble when using a catch all page routes on the top level (e.g.
/pages/[...slug].tsx
). When trying to call any API route, it seems to route incorrectly to the catch all page instead of hitting the API endpoint.
I've tried doing local dev/builds and deployed to Vercel with the same codebase but haven't been able to reproduce it in all other circumstances, so it looks like it only affects @cloudflare/next-on-pages
builds.
Has anyone encountered this problem before?
Regular catch all page:
https://dynamic-routes-api-404.pages.dev/home/page/
https://dynamic-routes-api-404.vercel.app/home/page/
API route:
https://dynamic-routes-api-404.pages.dev/api/hello/ (loads catch all page)
https://dynamic-routes-api-404.vercel.app/api/hello/ (loads API route)
Repo for repro: https://github.com/fong/dynamic-routes-api-404GitHub
GitHub - fong/dynamic-routes-api-404
Contribute to fong/dynamic-routes-api-404 development by creating an account on GitHub.
3 Replies
Also tried switching to
app
routing, but it still does the same thing:
https://dynamic-routes-api-404-app.pages.dev/api/hello/
https://dynamic-routes-api-404-app.vercel.app/api/hello/
https://github.com/fong/dynamic-routes-api-404-appGitHub
GitHub - fong/dynamic-routes-api-404-app
Contribute to fong/dynamic-routes-api-404-app development by creating an account on GitHub.
Please can you open an issue on the next-on-pages GitHub repository?
sure, opened one here: https://github.com/cloudflare/next-on-pages/issues/593
GitHub
[🐛 Bug]: dynamic page with catch all route overrides all API routes...
next-on-pages environment related information System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 CPU:...