Can you set the Host header using fetch API

被刻印的时光 ゝ 提交于 2019-12-09 16:32:28

问题


I have a reverse proxy server, which redirects you to different services depending on the Host header. However when making requests to this server using a browser, the Host is always set to the domain name in the URL. I tried:

fetch("http://foo.com", {"headers":{"Host":"bar.foo.com"}})

But it doesn't work


回答1:


Host is one of the forbidden header names:

A forbidden header name is an HTTP header name that cannot be modified programmatically.



来源:https://stackoverflow.com/questions/43285286/can-you-set-the-host-header-using-fetch-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!