尝试为Google身份validation器插入二维码图片时出现400错误请求

我正在尝试使用Google Authenticator在我的网站上设置双因素身份validation。 我能够生成工作代码,但是当我将图像URL插入到页面中时,在Chrome检查器中出现以下错误:

GET https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/MyLabel?secret=THESECRET 400 (Bad Request) 

生成QR码的代码:

 try key = crypto.randomBytes(10).toString('hex') catch error console.log "error generating code: #{error}" encoded = base32.encode(key) label = encodeURIComponent "MyLabel" uri = "otpauth://totp/#{label}?secret=#{encoded}" url = "https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=#{uri}" 

插入图像的客户端jQuery:

 img = $("<img>").attr("src", url) $("#qr_box").html("") $("#qr_box").append(img) 

这会导致页面上的以下HTML:

 <img src="https://www.google.com/chart?chs=200x200&amp;chld=M|0&amp;cht=qr&amp;chl=otpauth://totp/MyLabel?secret=THESECRET"> 

图像可以打开一个新的标签没有问题。 该图像只能在我的页面大约1/10时间成功显示; 其他时间铬给400.我在这里错过了明显的东西?

对我来说,它已经将https://www.google.com更改为https://chart.googleapis.com