a4b430e6f1
### 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> |
||
---|---|---|
.. | ||
app-dir | ||
app-dir-edge-runtime-with-wasm | ||
app-dir-hide-suppressed-error-during-next-export | ||
app-dir-prefetch-non-iso-url | ||
build-spinners | ||
ci-missing-typescript-deps | ||
custom-error-500 | ||
custom-server | ||
dependencies-can-use-env-vars-in-middlewares | ||
deployment-id-handling | ||
disable-fallback-polyfills | ||
edge-config-validations | ||
edge-runtime-is-addressable | ||
edge-safe-dynamic-code | ||
emit-decorator-metadata | ||
enoent-during-require | ||
escheck-output | ||
eslint-plugin-deps | ||
export | ||
exported-runtimes-value-validation | ||
fallback-export-error | ||
fatal-render-errror | ||
generate-middleware-source-maps | ||
handle-already-sent-response | ||
ipc-forbidden-headers | ||
jest | ||
middleware-typescript | ||
next-font | ||
pnpm-support | ||
postcss-plugin-config-as-string | ||
prerender-prefetch | ||
reading-request-body-in-middleware | ||
standalone-mode | ||
supports-module-resolution-nodenext | ||
typescript-basic |