[Solved] FlowRouter is grabbing my requests from WebApp

Hi, it seems like for some routes FlowRouter intercepts and then tries to treat as “not found”… there a way to get FlowRouter and Webapp to play nicely?

if I need to serve a server side route with webapp https://docs.meteor.com/packages/webapp.html to a route like https://localhost:3000/someroutepart1/someroutepart2 FlowRouter is sending back a “not found” (or actually showing my “not found” page).

When I go to http://localhost:3000/hello it works fine , with WebApp picking up that request.

Not sure what determines if FlowRouter grabs it before handing over to Webapp?

So, I need to get in before FlowRouter and the only way to do that is add me webapp code in a package before FlowRouter gets loaded? https://github.com/VeliovGroup/flow-router/issues/23#issuecomment-331670213

it seems like if I hit https://localhost:3000/someroutepart1 webapp gets it… .but as soon as I add some stuff ike someroutepart2 then it seems to grab it

Any help appreciated?

BTW, I did see this Make server respond with 404 status on unmatched URLs

Does this happen on navigation or on a fresh window/page load?

As far as I can see, FlowRouter doesn’t do any routing on the server side, it just includes stub implementations for SSR.
This means WebApp will always be used for fresh requests.

When the app is already loaded on the client however, the default in Meteor and FlowRouter is to work as a Single Page App (SPA), and manage all route transitions on the client.
This means no requests for the route are sent to the server.

This means if you an active client to make a request for a particular route to the server, you will need to instruct FlowRouter to do so.

Off the top of my head, using window.location = '/someroutepart1/someroutepart2' should work to destroy the current page and force a fresh request to the server:

FlowRouter.route('/someroutepart1/someroutepart2', {
  action() {
    // force window reload to new location.
    window.location = 'someroutepart1/someroutepart2';
  }
});

Alternatively, you could tell FlowRouter to make the request with XHR and do something with the result

@coagmanothanks for the quick reply.

Doh! I worked it out I had copied the param notation from my old ‘iron:router’ route… I need to parse the sting differently. with WebApp.

My bad.

1 Like

Hello @adamginsburg :wave:

FlowRouter can actually intercept requests before they reach WebApp , to avoid this:

  1. Place ostrio:flow-router-extra in order how you would like to load packages (after any other which can define WebApp handler);
  2. Import files on Server in order to place all WebApp handlers above (before) FlowRouter routes registration
1 Like

Thanks @dr.dimitru got it working

1 Like

What was the cause and how was it solved? :thinking: