我建立一个网站,不希望从指向重新配置的网站http://127.0.0.1来http://www.example.com.此外,我使用的证书当然是使用正确的域名制作的,www.example.com但我的测试环境会使调用127.0.0.1使安全性无法正常工作.
我目前要做的是配置我的开发环境以分配域名www.example.com,127.0.0.1以便将所有域http://www.example.com/xyz路由到http://127.0.0.1:8000/xyz并https://www.example.com/xyz路由到https://127.0.0.1:8080/xyz.
我没有使用Apache.我目前正在使用node.js作为我的Web服务器,而我的开发环境是在Mac OS X Lion中.
我从Google API Oauth收到此错误:
idpiframe_initialization_failed",详细信息:"不是客户端的有效来源:http://127.0.0....为项目的客户端ID列出此来源
我正在尝试从此本地路径发送请求:
我已将此URL添加到Authorized JavaScript origin部分:

这是我的代码:
<!-- The top of file index.html -->
<html itemscope itemtype="http://schema.org/Article">
<head>
<!-- BEGIN Pre-requisites -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
</script>
<!-- END Pre-requisites -->
<!-- Continuing the <head> section -->
<script>
function start() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: 'MY CLIENT ID.apps.googleusercontent.com',
// Scopes to request in addition to 'profile' and 'email'
//scope: 'https://www.google.com/m8/feeds/'
});
});
}
</script>
</head>
<body>
<button id="signinButton">Sign in …Run Code Online (Sandbox Code Playgroud) Google Cloud Platform oauth 服务最近进行了更新,强制所有重定向 URI 严格使用 HTTPS。但是,本地主机 url 应该被豁免,并且允许使用 http。更一般地说,验证规则在这里。
此后,我对公司的一些内部 Node Web 应用程序进行了更新,以符合新的 oauth 更改,并且它们在部署后可以完美运行。
我的问题是本地开发(在 http://localhost:4000 上)。每当我尝试在本地主机上通过 Google 登录时,都会收到模糊的 400 invalid_request 错误,指出我的应用程序不符合安全验证规则(已引用)。他们还为我提供了超链接到他们文档中有关安全性和 HTTPS 的部分。我坚信我的redirect_uri符合他们的安全标准(http://localhost:4000/login/google/callback)。我也绝对确定我在 Google 控制台凭据部分中的配置正确(无论如何,任何不匹配都将是一个 redirect_uri_mismatch 错误)。请告诉我我是否在这里遗漏了什么?我使用“passport-next/passport-google-oauth2”中间件包,同样,部署应用程序时没有任何问题。
我最近还注意到这里的其他几个人也有类似的未解决问题: