【发布时间】:2020-05-08 04:42:03
【问题描述】:
我确实在 localhost 中调用 POST api。由于服务器的一些要求,我必须通过真实的 url 修改标头中的 Origin 键。但它似乎仍然显示默认的 Origin 键。我可以更改 Content-Type 但 ORigin 不是。 ;)
我的功能是:
createItem() {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Origin': 'mywebsite'
})
};
const url = environment.apiUrl;
return this.http.post(url, data, httpOptions);
}
但在 Network 选项卡中,它仍然将 Origin 值显示为 locahost
Content-Type: application/json
Origin: http://localhost:4300 // I want my url here
【问题讨论】: