Correct way to get request host? #3644
-
Hi, I know I can route by host. But I want to create an endpoint for any host, and then return dynamically based on the host. So what I want to know is, should I check |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
According to the fetch spec,
Therefore the correct way is to get the host with You just need to be sure if you have any reverse-proxy, it's sending the Host header down to your runtime. Using Nginx with Deno, the host is available in the request URL. |
Beta Was this translation helpful? Give feedback.
According to the fetch spec,
req.headers
:Therefore the correct way is to get the host with
new URL(req.url).host
.You just need to be sure if you have any reverse-proxy, it's sending the Host header down to your runtime. Using Nginx with Deno, the host is available in the request URL.