rsnext/test/e2e/app-dir/app
Ngô Đức Anh a4b430e6f1
Better IPv6 support for next-server (#53131)
### What?
This PR makes it easier to use Next.js with IPv6 hostnames such as `::1` and `::`.

### How?
It does so by removing rewrites from `localhost` to `127.0.0.1` introduced in #52492. It also fixes the issue where Next.js tries to fetch something like `http://::1:3000` when `--hostname` is `::1` as it is not a valid URL (browsers' `URL` class throws an error when constructed with such hosts). It also fixes `NextURL` so that it doesn't accept `http://::1:3000` but refuse `http://[::1]:3000`. It also changes `next/src/server/lib/setup-server-worker.ts` so that it uses the server's `address` method to retrieve the host instead of our provided `opts.hostname`, ensuring that no matter what `opts.hostname` is we will always get the correct one.

### Note
I've verified that `next dev`, `next start` and `node .next/standalone/server.js` work with IPv6 hostnames (such as `::` and `::1`), IPv4 hostnames (such as `127.0.0.1`, `0.0.0.0`) and `localhost` - and with any of these hostnames fetching to `localhost` also works. Server Actions and middleware have no problems as well.

This also removes `.next/standalone/server.js`'s logging as we now use `start-server`'s logging to avoid duplicates. `start-server`'s logging has also been updated to report the actual hostname.
![image](https://github.com/vercel/next.js/assets/75556609/cefa5f23-ff09-4cef-a055-13eea7c11d89)
![image](https://github.com/vercel/next.js/assets/75556609/619e82ce-45d9-47b7-8644-f4ad083429db)
The above pictures also demonstrate using Server Actions with Next.js after this PR.
![image](https://github.com/vercel/next.js/assets/75556609/3d4166e9-f950-4390-bde9-af2547658148)

Fixes #53171
Fixes #49578
Closes NEXT-1510

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-08-14 07:23:24 +00:00
..
app App Router Preinitialize all required scripts except one for bootstrap (#53705) 2023-08-08 17:28:17 -07:00
pages test: pages react version with react hook in deployment (#48907) 2023-05-09 11:16:56 +02:00
public Load beforeInteractive scripts properly without blocking hydration (#41164) 2022-10-09 15:08:51 +00:00
styles Leverage mini css plugin hmr for app dir (#38830) 2022-07-21 14:38:04 +02:00
index.test.ts App Router Preinitialize all required scripts except one for bootstrap (#53705) 2023-08-08 17:28:17 -07:00
middleware.js Fix RSC navigation when overriding headers in middleware (#46049) 2023-02-17 16:34:35 +01:00
next.config.js Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
standalone.test.ts Better IPv6 support for next-server (#53131) 2023-08-14 07:23:24 +00:00
useReportWebVitals.test.ts Fix flaky css test and remove unused tests deps (#47806) 2023-04-01 16:58:32 -07:00
vercel-speed-insights.test.ts Update naming for Next.js Analytics (#48618) 2023-04-24 12:14:45 +02:00