Skip to content

Commit 2e5c8df

Browse files
styflenodejs-github-bot
authored andcommitted
doc: mention reverse proxy and include simple example
PR-URL: #59736 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 157cfde commit 2e5c8df

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/api/url.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,16 @@ function getURL(req) {
18571857
}
18581858
```
18591859
1860+
The example above assumes well-formed headers are forwarded from a reverse
1861+
proxy to your Node.js server. If you are not using a reverse proxy, you should
1862+
use the example below:
1863+
1864+
```js
1865+
function getURL(req) {
1866+
return new URL(req.url || '/', 'https://example.com');
1867+
}
1868+
```
1869+
18601870
### `url.resolve(from, to)`
18611871
18621872
<!-- YAML

0 commit comments

Comments
 (0)