Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Lissy93
Copy link

@Lissy93 Lissy93 commented May 18, 2024

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 with pages/api, which could include unrelated directories like pages/api-docs. This results in unnecessary confusion for developers not using Next.js for their project.

Changes

Updates the if statement in hasNextApiFiles to strictly check for files within pages/api/ or src/pages/api/, and NOT file names which just happen to start with the word api-. I also added a check to ensure that warnings related to Next.js API file placement are only shown if the project is indeed using Next.js.

Links

Fixes #11696

Copy link

changeset-bot bot commented May 18, 2024

⚠️ No Changeset found

Latest commit: c0a8136

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Lissy93

This comment was marked as resolved.

@Lissy93 Lissy93 changed the title Fix/prevent next api warn Fix/Prevent erounus Next.js API route warning, on non-Next.js apps May 19, 2024
@Lissy93
Copy link
Author

Lissy93 commented Jun 4, 2024

I've opened up a ticket, re: #11696
In case that's needed before a PR?

@Lissy93
Copy link
Author

Lissy93 commented Jun 6, 2024

Hey @EndangeredMassa and @TooTallNate - any chance for a review if you have a second?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Vercel CLI shows Next.js error if page begins with api-, even if Next.js is not present in project
1 participant