如何将请求头的来源从Localhhost更改为"*" [英] How to Change Origin of Request header from Localhhost to "*"

查看:337
本文介绍了如何将请求头的来源从Localhhost更改为"*"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

签出图片下面请做必要的帮助. 我想将请求标头的来源从本地主机更改为"*"或任何weburl.i,正在使用Ajax Call请求特定服务.谢谢.

Check out image Below Please Do needful help . I want to change the origin of the request header from local host to "*" or to any of weburl.i am using Ajax Call for requesting the specific Service. Thanks.

推荐答案

当JavaScript要求浏览器发出HTTP请求时,您无法更改浏览器发送的Origin标头. (至少Firefox将忽略对其进行设置的尝试.)

You cannot change the Origin header the browser sends when your JavaScript asks it to make an HTTP request. (Firefox, at least, will ignore attempts to set it).

无论如何都没有任何改变.标头的目的是使服务器可以授予多个不同来源的CORS权限,而不必授予所有来源的权限.如果默认情况下服务器未使用*进行响应,则它不会查看您说的来源,并确定突然可以接受*.

There isn't any point in changing it anyway. The point of the header is so that a server can grant permissions with CORS for multiple different origins without granting permission for all origins. If the server isn't responding with * by default then it isn't going to look at the Origin you say you are from and decide that * is suddenly acceptable.

您需要解决服务器而非客户端上的跨域问题.

You need to address the cross-origin issues on the server, not the client.

这篇关于如何将请求头的来源从Localhhost更改为"*"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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