Skip to content

Commit 66d90b8

Browse files
styfletargos
authored andcommitted
doc: mention reverse proxy and include simple example
PR-URL: #59736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 14aa111 commit 66d90b8

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
@@ -1851,6 +1851,16 @@ function getURL(req) {
18511851
}
18521852
```
18531853
1854+
The example above assumes well-formed headers are forwarded from a reverse
1855+
proxy to your Node.js server. If you are not using a reverse proxy, you should
1856+
use the example below:
1857+
1858+
```js
1859+
function getURL(req) {
1860+
return new URL(req.url || '/', 'https://example.com');
1861+
}
1862+
```
1863+
18541864
### `url.resolve(from, to)`
18551865
18561866
<!-- YAML

0 commit comments

Comments
 (0)