createWebRequestFromNodeRequest
function
Converts a Node.js IncomingMessage or Http2ServerRequest into a
Web Standard Request object.
API
function createWebRequestFromNodeRequest(
nodeRequest: IncomingMessage | Http2ServerRequest,
trustProxyHeaders?: boolean | readonly string[] | undefined,
): Request;@paramnodeRequest
IncomingMessage | Http2ServerRequest- The Node.js request object (
IncomingMessageorHttp2ServerRequest) to convert.
@paramtrustProxyHeaders
boolean | readonly string[] | undefined- A boolean or an array of proxy headers to trust when constructing the request URL.
@returns
RequestA Web Standard Request object.
Description
Converts a Node.js IncomingMessage or Http2ServerRequest into a
Web Standard Request object.
This function adapts the Node.js request objects to a format that can be used by web platform APIs.
Usage Notes
When trustProxyHeaders is enabled, headers such as X-Forwarded-Host and
X-Forwarded-Prefix should ideally be strictly validated at a higher infrastructure
level (e.g., at the reverse proxy or API gateway) before reaching the application.
Jump to details