Skip to content

Instantly share code, notes, and snippets.

@zachariahtimothy
Created November 2, 2015 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachariahtimothy/4e150b3931e4f299138e to your computer and use it in GitHub Desktop.
Save zachariahtimothy/4e150b3931e4f299138e to your computer and use it in GitHub Desktop.
Sets up context for using CollectionsFS with FlowRouterSSR. Allows the .url() function to work server side.
//Hack to make CollectionFS work with FlowRouter.
if (Meteor.isServer) {
let originalFind = Collections.Media.find;
let originalFindOne = Collections.Media.findOne;
Collections.Media.__proto__.findOne = function (selector, options) {
let self = this;
return FlowRouter.ssrContext.withValue(null, function() {
return originalFindOne.call(self, selector, options);
});
};
Collections.Media.__proto__.find = function (selector, options) {
let self = this;
return FlowRouter.ssrContext.withValue(null, function() {
return originalFind.call(self, selector, options);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment