rsnext/test/lib
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
..
browsers [chore] Upgrade playwright to 1.35.1 (#53875) 2023-08-11 23:25:01 +00:00
next-modes test(turbo): allow to run test with --experimental-turbo (#53396) 2023-08-09 05:48:54 +00:00
amp-test-utils.js Improve linting rules to catch more errors (#9374) 2019-11-10 19:24:53 -08:00
create-next-install.js Revert "Implement new forking technique for vendored packages. (#51083)" (#53640) 2023-08-06 13:00:12 -07:00
development-sandbox.ts fix app-hmr-changes.test.ts by updating next-tweet (#52046) 2023-06-30 23:09:09 +00:00
e2e-utils.ts test(turbo): allow to run test with --experimental-turbo (#53396) 2023-08-09 05:48:54 +00:00
flat-map-polyfill.js Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
mocks-require-hook.js Validate streaming writer chunk type in testing (#36200) 2022-04-18 16:24:06 +02:00
next-test-utils.ts Better IPv6 support for next-server (#53131) 2023-08-14 07:23:24 +00:00
next-webdriver.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
react-channel-require-hook.js Preload css (#48840) 2023-04-27 12:51:52 +02:00
turbo.ts test(turbo): allow to run test with --experimental-turbo (#53396) 2023-08-09 05:48:54 +00:00
use-temp-dir.ts fix(cli): handle Tailwind CSS + src/ correctly (#47238) 2023-03-20 14:21:29 -07:00