rsnext/packages/next/server
Javi Velasco 85cc454023
Add port and hostname options to Next Server (#31858)
A middleware can work as a proxy intercepting requests and then performing a `fetch` to the destination adding headers to the request / response as a "man in the middle". When using `fetch` from a middleware we are not in the context of a browser so we can't really use relative URLs, they must be always absolute.

Now consider the previous case when middleware is running in *server mode*. Typically in order to know the host where we are fetching we can use the `request.nextUrl` which is given to the middleware but in this case the invoker (which is next-server) has no context of the hostname, nor the port. To solve this use case we must make the invoker of the middleware aware of the origin hostname and port.

This PR: 

- Introduces `hostname` and `port` as options for `NextServer`.
- Refactors types in `NextServer` and `NextDevServer` moving type only imports to the top of the file.
- Refactors `startServer` to do a best guess on the `hostname` and `port`, passing them down.
- Exposes `.port` and `.hostname` to be retrieved from the `app`.

In an upcoming PR we will pass the host guess to the middleware to solve the relative URL issue.
2021-11-28 16:48:43 +00:00
..
dev Add port and hostname options to Next Server (#31858) 2021-11-28 16:48:43 +00:00
lib Add port and hostname options to Next Server (#31858) 2021-11-28 16:48:43 +00:00
web Refactor sandbox module cache (#31822) 2021-11-26 12:06:41 +00:00
accept-header.ts Implement Middleware RFC (#30081) 2021-10-20 17:52:11 +00:00
api-utils.ts Add new target for middleware (#30299) 2021-10-26 18:50:56 +02:00
config-shared.ts Add support for removing React properties. (#31606) 2021-11-26 14:45:03 +01:00
config-utils.ts Remove webpack 4 support (#29660) 2021-10-06 17:40:01 +02:00
config.ts Relax restriction of images.path in next.config.js (#30741) 2021-11-02 00:00:47 +00:00
crypto-utils.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
denormalize-page-path.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
font-utils.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
get-page-files.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
get-route-from-entrypoint.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
htmlescape.ts Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
image-config.ts Change AVIF to opt-in via configuration (#30180) 2021-10-22 21:08:03 +00:00
image-optimizer.ts Adjust AVIF size so that its smaller than WebP size (#31494) 2021-11-17 20:31:16 +00:00
incremental-cache.ts Fix revalidate for initial notFound: true paths (#28097) 2021-08-14 13:11:40 +00:00
load-components.ts Add new target for middleware (#30299) 2021-10-26 18:50:56 +02:00
next-server.ts Add port and hostname options to Next Server (#31858) 2021-11-28 16:48:43 +00:00
next.ts Add port and hostname options to Next Server (#31858) 2021-11-28 16:48:43 +00:00
node-polyfill-fetch.js Add next.config.js option to override default keepAlive (#27709) 2021-08-03 00:38:42 +00:00
normalize-page-path.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
optimize-amp.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
render-result.ts Add new target for middleware (#30299) 2021-10-26 18:50:56 +02:00
render.tsx Fix auto export condition in edge SSR (#31845) 2021-11-26 15:53:38 +00:00
request-meta.ts Fix middleware i18n rewrites (#31174) 2021-11-09 01:28:39 +00:00
require.ts Add new target for middleware (#30299) 2021-10-26 18:50:56 +02:00
response-cache.ts upgrade to typescript 4.4.3 (#29112) 2021-09-16 18:06:57 +02:00
router.ts Fix basePath replacing server-side and normalizeLocalePath() when path is empty string (#30978) 2021-11-15 17:33:21 +00:00
send-payload.ts Simplify RenderResult (#28900) 2021-09-08 16:56:31 +00:00
serve-static.ts Add support for AVIF to next/image (#29683) 2021-10-11 23:17:47 +00:00
utils.ts Add detection for Google-PageRenderer bot (#31521) 2021-11-17 03:49:37 +00:00