Angular 角度-无法设置HttpHeader键原点
我在localhost中调用postapi。由于服务器的一些要求,我必须用一个真实的url修改标题中的源密钥。但它似乎仍然显示默认的原始密钥。我可以更改内容类型,但无法更改来源。;) 我的职能是:Angular 角度-无法设置HttpHeader键原点,angular,api,post,header,Angular,Api,Post,Header,我在localhost中调用postapi。由于服务器的一些要求,我必须用一个真实的url修改标题中的源密钥。但它似乎仍然显示默认的原始密钥。我可以更改内容类型,但无法更改来源。;) 我的职能是: createItem() { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Origin': 'mywebsite'
createItem() {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Origin': 'mywebsite'
})
};
const url = environment.apiUrl;
return this.http.post(url, data, httpOptions);
}
但在“网络”选项卡中,它仍将原点值显示为locahost
Content-Type: application/json
Origin: http://localhost:4300 // I want my url here
你不能:
如MDN所述;Origin是一个“禁止”标题,这意味着您不能通过编程方式更改它
非常感谢。我将从服务器端请求更新