2013-10-29 116 views
0

我與流星有關的問題0.6.6.2流星URL前綴

當我在生產上部署時。我有以下錯誤:

/home/gt/webapps/meteor/bundle/programs/server/boot.js:185 
}).run(); 
^
Error: a route URL prefix must begin with a slash 
    at _.extend.declare (packages/routepolicy/routepolicy.js:95) 
    at new StreamServer (packages/livedata/stream_server.js:23) 
    at new Server (packages/livedata/livedata_server.js:980) 
    at Package (packages/livedata/server_convenience.js:10) 
    at packages/livedata.js:3909:4 
    at packages/livedata.js:3920:3 
    at /home/gt/webapps/meteor/bundle/programs/server/boot.js:154:10 
    at Array.forEach (native) 
    at Function._.each._.forEach (/home/gt/webapps/meteor/bundle/programs/server/node_modules/underscore/underscore.js:79:11) 
    at /home/gt/webapps/meteor/bundle/programs/server/boot.js:81:5 

我root_url設置爲:

出口ROOT_URL = 'http://sub.mydomain.com'

我沒有問題與舊版本流星的。

回答

2

我發現了錯誤。我調試routepolicy.js中的路徑(在/ bundle/programs/server/app中使用console.info(urlPrefix)第56行),發現我的export ROOT_URL不正確。 出於某種原因,我的export命令(出口ROOT_URL = 'http://mydomain.com '不是全成和它仍然ROOT_URL =' mydomain.com')

參見: Github的問題:https://github.com/meteor/meteor/issues/1404

0

您是否在某處使用中間件或服務器端路由?如果是這樣,則中間件的所有path參數必須以/開頭,因此請將some/path更改爲/some/path。它在最近的一個版本中開始變得重要。

ROOT_URL不必以/結尾,順便說一句 - 你的答案是正確的。

+0

有沒有辦法讓我調試並找出錯誤來自哪裏? – gpasse

+0

@gpasse你有任何軟件包或者你製作服務器端路由的東西嗎?如鐵路由器或流星路由器? – Akshat

+0

我不知道如何查明錯誤。然而,搜索你的服務器代碼和包「WebApp.connectHandlers」和「WebApp.stack」可能會導致所有可能的地方。 –

0

這裏是什麼我做支持(使用鐵路由器)命名空間中的路線:

lib/namespace.js包含:

Router._mapOld = Router.map; 

Router.map = function(namespace, cb) { 
    if (_.isFunction(namespace)) { 
     cb = namespace; 
     return Router._mapOld.call(this, cb); 
    } 

    namespace = namespace.replace(/\/+$/, ''); 

    var that  = this; 
    that._routeOld = that.route; 
    that.route  = function(name, options) { 
     if (!_.isString(options.path)) { 
      throw new Error(
       'Namespaced routes must have a path specified as a string.'); 
     } 
     return that._routeOld.call(that, name, _.extend(options, { 
      path : namespace + options.path 
     })); 
    }; 

    var ret = Router._mapOld.call(that, cb); 

    that.route = that._routeOld; 

    return ret; 
}; 

然後,你可以這樣做:

Router.map(function() { 
    // Add routes normally with no prefix 
}); 

Router.map('/prefix', function() { 
    // All routes you add here will be prefixed with /prefix 
});