在Chrome中加载analytics.js时重定向307 [英] 307 Redirect when loading analytics.js in Chrome

查看:767
本文介绍了在Chrome中加载analytics.js时重定向307的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网络应用并使用Google Analytics(analytics.js)进行分析。我最近注意到,分析在Chrome中无法正常工作。



我使用标准代码片段在单独的模块中加载分析,并通过requirejs进行加载。我已验证此脚本按预期运行,并执行分析代码片段。



当我检查Firefox中的网络流量时,可以看到分析脚本是从Google加载的如预期的那样(HTTP 200响应):

p>



但是,如果我将分析网址直接粘贴到Chrome地址栏中,则会找到该脚本。任何想法发生在这里,或者如何解决它? 内部重定向 with Non-Authorative-Reason:Delegate 表示请求被Chrome扩展程序通过 webRequest 声明性webRequest 扩展API。



您可以找出哪个扩展触发了重定向,如下所示:


  1. 访问 chrome:// net-internals /#events

  2. 触发请求)返回到 chrome:// net-internals /#events 标签并查找与您的请求匹配的URL_REQUEST (您可以使用搜索框来过滤搜索)。

  3. 点击条目以在右侧显示日志。您将看到有关请求的扩展名,扩展ID和其他信息:



 
t = 7910 [st = 0] + REQUEST_ALIVE [dt = 6]
t = 7910 [st = 0] + URL_REQUEST_DELEGATE [dt = 5]
t = 7910 [st = 0] DELEGATE_INFO [dt = 5]
< b> - > delegate_info =extension [扩展名]
t = 7915 [st = 5] CHROME_EXTENSION_REDIRECTED_REQUEST
- > extension_id =ebmlimjkpnhckbaejoagnjlgcdhdnjlb

t = 7915 [ st = 5] -URL_REQUEST_DELEGATE
t = 7915 [st = 5] + URL_REQUEST_START_JOB [dt = 1]
- > load_flags = 339804160(BYPASS_DATA_REDUCTION_PROXY | MAYBE_USER_GESTURE | REPORT_RAW_HEADERS | VERIFY_EV_CERT)
- > method =GET
- > priority =LOW
- > url =https://www.google-analytics.com/analytics.js
t = 7915 [st = 5] URL_REQUEST_REDIRECT_JOB
- > reason =委托
t = 7915 [st = 5] URL_REQUEST_FAKE_RESPONSE_HEADERS_CREATED
- > HTTP / 1.1 307内部重定向
位置:about:空白
非权威原因:委托

在此日志示例中,名为[扩展名]和扩展名ebmlimjkpnhckbaejoagnjlgcdhdnjlb的扩展名将该请求重定向。找到扩展名和/或ID后,您可以访问 chrome:// extensions ,并禁用或删除修改请求的扩展名。


I'm building a web app and using Google Analytics (analytics.js) for analytics. I recently noticed that analytics aren't working properly in Chrome.

I'm loading analytics using the standard code snippet in a separate module and included via requirejs. I've verified that this script runs as expected and executes the analytics snippet.

When I inspect network traffic in Firefox, I can see that the analytics script is loaded from Google as expected (HTTP 200 response):

However, when I run the exact same page in Chrome, I get an HTTP 307 response pointing to about:blank, and analytics does not run:

However, if I paste the analytics URL directly into the Chrome address bar, the script is found. Any ideas what's going on here, or how to fix it?

解决方案

307 Internal Redirect with Non-Authorative-Reason: Delegate indicates that the request was intercepted and modified (redirected) by a Chrome extension via the webRequest or declarative webRequest extension APIs.

You can find out which extension triggered the redirect as follows:

  1. Visit chrome://net-internals/#events
  2. Trigger the request (google analytics, in your case).
  3. Go back to the chrome://net-internals/#events tab and look for a URL_REQUEST matching your request (you can use the searchbox to filter the search).
  4. Click on the entry to show the log at the right side. You will see the extension name, extension ID and other information about the request:

t=7910 [st=0] +REQUEST_ALIVE  [dt=6]
t=7910 [st=0]   +URL_REQUEST_DELEGATE  [dt=5]
t=7910 [st=0]      DELEGATE_INFO  [dt=5]
                   --> delegate_info = "extension [Name of extension]"
t=7915 [st=5]      CHROME_EXTENSION_REDIRECTED_REQUEST
                   --> extension_id = "ebmlimjkpnhckbaejoagnjlgcdhdnjlb"
t=7915 [st=5]   -URL_REQUEST_DELEGATE
t=7915 [st=5]   +URL_REQUEST_START_JOB  [dt=1]
                 --> load_flags = 339804160 (BYPASS_DATA_REDUCTION_PROXY | MAYBE_USER_GESTURE | REPORT_RAW_HEADERS | VERIFY_EV_CERT)
                 --> method = "GET"
                 --> priority = "LOW"
                 --> url = "https://www.google-analytics.com/analytics.js"
t=7915 [st=5]      URL_REQUEST_REDIRECT_JOB
                   --> reason = "Delegate"
t=7915 [st=5]      URL_REQUEST_FAKE_RESPONSE_HEADERS_CREATED
                   --> HTTP/1.1 307 Internal Redirect
                       Location: about:blank
                       Non-Authoritative-Reason: Delegate

In this log sample, an extension with name "[Name of extension]" and extension ID "ebmlimjkpnhckbaejoagnjlgcdhdnjlb" redirected the request. After finding the extension name and/or ID, you can visit chrome://extensions and disable or remove the extension that modified the request.

这篇关于在Chrome中加载analytics.js时重定向307的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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