-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/Prevent erounus Next.js API route warning, on non-Next.js apps #11611
base: main
Are you sure you want to change the base?
Conversation
|
I'm sorry for the direct PR, without any issue attached (issues are disabled for this repo). If it helps, and you'd like to create a ticket for this, here's content which can go into a bug report: SummaryWhen using the Vercel CLI with an Astro app (without React or Next.js), any pages which start with
Steps to Reproduce
Minimal reproducible example: https://stackblitz.com/edit/github-yogmzg-d6z7xm Expected BehaviorNo warnings. Because everything is 200 okay :) Actual BehaviorUser sees a barage of warnings from the Vercel CLI, informing them not to put Next.js API routes in Astro pages. This occours on a totally vanillar Astro app, with no traces of either React nor Next.js, just because they have an Astro route beginning with Environment InfoVercel CLI: 34.2.0 Areas AffectedVercel CLI Root CauseThis is caused by vercel/packages/fs-detectors/src/detect-builders.ts Lines 215 to 220 in 80e0bab
Which then results in an warning message being repeatidly displayed vercel/packages/fs-detectors/src/detect-builders.ts Lines 335 to 347 in 80e0bab
This feature appears to have been added in #3784 (specifically, this commit specifically). SolutionThe solution is to either implement one of the following: Hope that helps 💖 |
Summary
This PR resolves an issue where developers receive misleading warnings about the placement of API files in non-Next.js projects hosted on Vercel.
The current logic triggers a warning when any file under the
pages/
directory loosely starts withpages/api
, which could include unrelated directories likepages/api-docs
. This results in unnecessary confusion for developers not using Next.js for their project.Changes
hasNextApiFiles
to strictly check for files withinpages/api/
orsrc/pages/api/
, and NOT file names which just happen to start with the wordapi-
options.projectSettings.framework
to verify the framework type before issuing a warning.