Repository: next.js
Issue: Cannot use a path named '/pages/[id]' with app router and edge runtime on Vercel. Next 14.04
Labels: bug,Runtime

### Link to the code that reproduces this issue

https://github.com/Martoxdlol/next-on-vercel-error-pages-named-path-with-params

### To Reproduce

1. Deploy to vercel
2. Open `/pages/1` or /pages/any-other-param` on the production deployment on Vercel.

### Current vs. Expected behavior

In dev mode it show the expected page under `/pages/[id]` (using any id, for example `/pages/1`). It is using the file with path `/app/pages/[id]/page.tsx`.
In production mode locally does the same (it works as expected).

If I access the same route on Vercel it throws a 500 internal server error.

https://next-on-vercel-error-pages-named-path-with-params.vercel.app/pages/1

This happen only with edge runtime I think.

![image](https://github.com/vercel/next.js/assets/35405382/3c460179-4cd2-4a89-b13e-a55496fcb61a)

In the deployment summary it shows that it is not using the edge runtime when it should. Also it show the route `/[id]` wich doesn't really exist. If I try to access it, it throws a 404.

On Vercel:
![image](https://github.com/vercel/next.js/assets/35405382/7f7bf5a5-a943-4b96-a6c6-50120d4526c6)

Local dev mode (using next dev):
![image](https://github.com/vercel/next.js/assets/35405382/29ad9f31-5d12-4631-9419-308402f6d79d)


Local production mode (using next build and next start):
![image](https://github.com/vercel/next.js/assets/35405382/d6e0288c-861d-4eb1-bc2c-a9500b54cdd1)


### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: 8.7.4
Relevant Packages:
  next: 14.0.5-canary.40
  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)

### Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

### Additional context

I did some extra testing in this repo: https://github.com/Martoxdlol/vercel-next-14-pages-named-dir-bug-in-app-router

If I use the same setup but the dir is called `not-pages` instead of `pages` it works.

Also, if I don't use a route with params it also works. (example: `/pages/page.tsx` -> it works)

Vercel logs:

![image](https://github.com/vercel/next.js/assets/35405382/c95d05ab-1b16-49b4-9342-a4425523e2cd)

```
ReferenceError: self is not defined
    at Object.<anonymous> (/var/task/.next/server/app/pages/[id]/page.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at r.<computed>.e._load (/var/task/___vc/__launcher/bridge-server-72TT5FOD.js:1:1574)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at E.require (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:11:25840)
    at require (node:internal/modules/cjs/helpers:119:18)
    at rb (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:10382) {
  page: '/pages/1'
}
```