我正在使用meteor accounts-facebook,并希望按照Facebook的要求使用SSL,但redirect_uri
将作为http://
传递,即使应用程序在{{1}上运行}}。在facebook-oauth.js中创建https://
的代码如下:
loginUrl
再次调用OAuth:
var loginUrl =
'https://www.facebook.com/v2.9/dialog/oauth?client_id=' + config.appId +
'&redirect_uri=' + OAuth._redirectUri('facebook', config) +
'&display=' + display + '&scope=' + scope +
'&state=' + OAuth._stateParam(loginStyle, credentialToken, options && options.redirectUrl);
如果OAuth._redirectUri = function (serviceName, config, params, absoluteUrlOptions) {
...
Meteor.absoluteUrl('_oauth/' + serviceName, absoluteUrlOptions)
...
}
为真,则在Meteor.absoluteUrl之前首先删除SSL,然后再将其删除:
Meteor.absoluteUrl.defaultOptions.secure
我看不出办法:
// merge options with defaults
options = Object.assign({}, Meteor.absoluteUrl.defaultOptions, options || {});
...
if (!/^http[s]?:\/\//i.test(url)) // url starts with 'http://' or 'https://'
url = 'http://' + url; // we will later fix to https if options.secure is set
...
// turn http to https if secure option is set, and we're not talking
// to localhost.
if (options.secure &&
/^http:/.test(url) && // url starts with 'http:'
!/http:\/\/localhost[:\/]/.test(url) && // doesn't match localhost
!/http:\/\/127\.0\.0\.1[:\/]/.test(url)) // or 127.0.0.1
url = url.replace(/^http:/, 'https:');
参数传递给absoluteUrlOptions
OAuth._redirectUri
我唯一的解决方法是安装Meteor.absoluteUrl.defaultOptions.secure
所以整个应用程序都在https上强制运行。
答案 0 :(得分:0)
解决方法是安装force-ssl,以便整个应用程序在https上运行。
meteor add force-ssl
更新:显然您也可以在应用程序的早期将Meteor.absoluteUrl.defaultOptions.secure = true
设置在正确的位置,例如client/lib/...