Can I install another route handler via __meteor_bootstrap__.app?

I am creating my first meteorite application and should be able to create a new route handler to handle the oauth callback. I looked at server.js and found that the connect.app context is available in meteor_bootstrap . Although this does not seem to work:

if (Meteor.is_server) { Meteor.startup(function () { var app = __meteor_bootstrap__.app; app.use('/callback',function (req,res) { res.writeHead(404); res.end(); return; }); }); } 

Thoughts?

+7
meteor
Apr 12 2018-12-12T00:
source share
3 answers

The problem with this solution is that your middleware is pushed to the bottom of the stack. Therefore, the meteor catch handler will always work before your "/ callback".

One very hacky way around this (until the meteorite issues its proper routing support) is to splic your handler at the top of the stack:

 __meteor_bootstrap__.app.stack.splice (0, 0, { route: '/hello', handle: function (req,res, next) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end("hello world"); return; }.future () }); 
+8
Jun 05 2018-12-12T00:
source share

You can achieve this with the Meteor Router :

 Meteor.Router.add({ '/callback': 404 }) 
+6
Dec 06
source share

Some of the answers lead to the fact that routing now does not go to the server without being hacked. This is a known issue and sounds like routing - this is a hot item in the task list.

+2
Apr 13 '12 at 23:17
source share



All Articles