您可以使用访存API设置主机标头吗 [英] Can you set the Host header using fetch API

查看:83
本文介绍了您可以使用访存API设置主机标头吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个反向代理服务器,它可以根据Host标头将您重定向到其他服务. 但是,当使用浏览器向该服务器发出请求时,Host始终设置为URL中的域名.我试过了:

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"}})

但这不起作用

推荐答案

Host 禁止的标头名称 :

禁止的标头名称是无法通过编程方式修改的HTTP标头名称.

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

这篇关于您可以使用访存API设置主机标头吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆