I’m trying to convert an app from iron router to flow router and hit a problem with a server route. Using iron router I had a download link like this:
<a href="/files/{{_id}}" class="btn btn-default">
Download {{title}}
</a>
and a server route like this:
Router.route('/files/:_id', {
where: 'server',
action: function() {
var a = Things.findOne(this.params._id),
b = transformedThing(t);
this.response.writeHead(200, {
'Content-disposition': 'attachment; filename=' + t.title,
'Content-type': 'application/octet-stream'});
this.response.end(new Buffer(b));
}
});
I changed the server route to use meteorhacks:picker like this:
Picker.route('/files/:_id', function(params, req, res, next) {
var a = Things.findOne(this.params._id),
b = transformedThing(t);
res.writeHead(200, {
'Content-Disposition': 'attachment; filename=' + t.title,
'Content-Type': 'application/octet-stream' });
res.end(new Buffer(b));
});
The server route seems to be working. Where I’m stuck is how do I get the client to know about that route?
1 Like
Did you read the post? He’s using it
@caedmon what’s happening when you’re going to the route?
I get the following on the client:
There is no route for the path: /files/w5zkMtPosFs6G5PehRouter._notfoundRoute @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:1929(anonymous function) @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:21013.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:608nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4403.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextEnter @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:440nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4283.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:429Triggers.runTriggers @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:1580Router.route.route._exitHandle @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:17133.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:608nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.Route.middleware @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:609nextExit @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4293.page.dispatch @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:4443.page.show @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:335Router.initialize._.each.self._page.(anonymous function) @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:1962onclick @ kadira_flow-router.js?27ee48c1f8aeb66e86562d593ab02648ea96fbbb:735
It seems as though flow router expects to find a defined route on the client.
I tried to reply with the full stack trace but that didn’t make it past Akismet.
What I see in the browser is this exception:
There is no route for the path: /files/Lf34kwdLrSCFrGSyy
at kadira_flow-router.js:1929
what happens if you prefix your route with http:// + window.location.hostname + file… ?
@keithnicholas that gives the same result.
edit: what I actually used was: window.location.origin + “/files/” + _id
After a little spelunking in flow router I was able solve the problem by adding a ‘download’ attribute to the <a>
.
1 Like