致电:
FlowRouter.url("myRouteName");
我得到了服务器的IP地址,即
"http://XX.XXX.XX.XXX/loggedin/my-route"
而不是FQDN,即
"http://example.com/loggedin/my-route"
知道如何正确配置吗?
感谢。
答案 0 :(得分:0)
回答我自己的问题。 Source
Router.prototype.url = function() {
// We need to remove the leading base path, or "/", as it will be inserted
// automatically by `Meteor.absoluteUrl` as documented in:
// http://docs.meteor.com/#/full/meteor_absoluteurl
var completePath = this.path.apply(this, arguments);
var basePath = this._basePath || '/';
var pathWithoutBase = completePath.replace(new RegExp('^' + basePath), '');
return Meteor.absoluteUrl(pathWithoutBase);
};
所以似乎FlowRouter正在使用Meteor.absoluteUrl
。
现在可以使用Meteor.absoluteUrl.defaultOptions.rootUrl = "http://example.com"
设置绝对路径但是这对我来说不是正确的方法,因为我的应用实际上可以提供多个域名。
所以我必须编写自己的函数,它可以从客户端提取FQDN。
flowRouterUrl = function(id, params, queryParams) {
return window.location.protocol + "//" + window.location.host + FlowRouter.path(id, params, queryParams);
}
flowRouterUrl("myRoute");
返回
http://example.com/loggedin/my-route
我正在追求的是什么。