It looks like when you send off a request using the $http service, the referer header is set to the base url without the angular $location information.
看起来当您使用$ http服务发送请求时,referer标头设置为基本URL而没有angular $ location信息。
How do you go about appending the $location.path() to that header for all requests?
如何将$ location.path()附加到所有请求的标头?
Our API calls will log that referer header when an error occurs; however, it would be very helpful if we could store the user's actual location ("*.com/#/question/1234" opposed to just "*.com/")
我们的API调用将在发生错误时记录该引用标头;但是,如果我们可以存储用户的实际位置(“*.com/#/question/1234”与“*.com/”相对,那将非常有用)
1 个解决方案
#1
3
I ended up just doing something like this:
我最后只做了这样的事情:
$httpProvider.interceptors.push(function ($location) {
return {
request: function (config) {
config.headers["RefererFullUrl"] = $location.absUrl();
return config;
}
};
});
It doesn't look like the browsers are too happy if you try to change the 'referer' url, so I'm just naming it something else, and looking for that header specifically on the server
如果你试图更改'referer'网址,看起来浏览器看起来并不太高兴,所以我只是将其命名为其他内容,并在服务器上专门查找该标头
#1
3
I ended up just doing something like this:
我最后只做了这样的事情:
$httpProvider.interceptors.push(function ($location) {
return {
request: function (config) {
config.headers["RefererFullUrl"] = $location.absUrl();
return config;
}
};
});
It doesn't look like the browsers are too happy if you try to change the 'referer' url, so I'm just naming it something else, and looking for that header specifically on the server
如果你试图更改'referer'网址,看起来浏览器看起来并不太高兴,所以我只是将其命名为其他内容,并在服务器上专门查找该标头