Mup deploy errors when using webapp.connecthandlers

I am trying to implement 301 redirection when visiting my www address to redirect to non-www. redirection works on localhost, and the project builds fine. when I try to deploy with mup, I get this error:

x Invoking deployment process: FAILED -----------------------------------STDERR----------------------------------- :callback' will be initialized after [-Wreorder] v8::Handle<v8::Function> callback; ^ ../src/heap_output_stream.h:26:29: warning: 'v8::Handle<v8::Value> nodex::OutputStreamAdapter::abort' [-Wreorder] v8::Handle<v8::Value> abort; ^ ../src/heap_output_stream.h:11:7: warning: when initialized here [-Wreorder] OutputStreamAdapter( ^ gyp info ok npm WARN package.json meteor-dev-bundle@0.0.0 No description npm WARN package.json meteor-dev-bundle@0.0.0 No repository field. npm WARN package.json meteor-dev-bundle@0.0.0 No README data % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 80: Connection refused Latest deployment failed! Reverted back to the previous version. 

here is the violation code. mup works fine when I delete it. these codes live in /lib/_reroute-non-www.js

 if( Meteor.isServer ){ WebApp.connectHandlers.use(function(req, res, next){ if( req.headers.host == 'www.example.com' ){ res.writeHead(301, { Location: 'https://example.com' }) res.end() } else { next() } }) } 

what does it all mean?

+5
source share
1 answer

Although I'm not quite sure why this particular set of code calls mup to "throw" like this, I found other reasons that might be related.

When using RabbitMQ (via Wascally ) my consumer handlers must be registered with

 Fiber(()=>{ rabbit.handle(key, consumerFn) }).run() 

... and inside consumeFn() I don't have a Meteor environment! There is no Meteor , and I do not have access to collections that could be defined in my application.

What I managed to do was use Meteor.bindEnvironment for my promise handler then , which was returned when I registered the handler. Using Meteor.bindEnvironment gives me access to all the things that I expect to have in my Meteor application.

 Wascally.request(key, {content: 'my content'}) .then(Meteor.bindEnvironment((result)=>{ // now i have access to my Meteor environment and all collections })) 
0
source

Source: https://habr.com/ru/post/1232988/


All Articles