-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Description
Bug report
Describe the bug
There is a naming conflict bug for files or folders in the root of /pages that start with api i.e. /pages/api-test.js or /pages/api-test/index.js that results in a 404. This bug seems to be result of this line of code /packages/next/build/entries.ts. Files or folders that begin with the name api in the root of the /pages folder receive the following error in the console:
Failed to load resource: the server responded with a status of 404 (Not Found)
Additionally clicking on a element with an onClick event is unresponsive. Example /pages/api-test.js.
To Reproduce
Repository
https://github.com/khasty720/next-js-api-name-conflict
Live Example
https://nextjs-iv9d3ozsv.now.sh/
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to http://localhost:3000 or https://nextjs-iv9d3ozsv.now.sh
- Click on 'API Test'
- Open console
- See error:
Failed to load resource: the server responded with a status of 404 (Not Found)
Expected behavior
Clicking on alert link does not work on http://localhost:3000/api-test. The same Alert component does work on http://localhost:3000/alert-test. The expected behavior is that the page will load and not throw a 404.
System information
- Version of Next.js: 9.0.1
Additional context
Additional places where /api is referenced:
https://github.com/zeit/next.js/blob/canary/packages/next/build/entries.ts#L71
https://github.com/zeit/next.js/blob/canary/packages/next/build/webpack/loaders/next-serverless-loader.ts#L42
https://github.com/zeit/next.js/blob/canary/packages/next/build/index.ts#L324
https://github.com/zeit/next.js/blob/canary/packages/next/build/entries.ts#L71