Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving an "index.html" file in public/ when using MeteorJS and Iron Router?

I want to serve a static HTML file from MeteorJS's public folder (as is possible with Rails and Express). The reason I'm doing this is because I have one template for the dynamic "admin" part of my webapp and another for the sales-y "frontend" part of the app.

I don't want this file to be wrapped in a Meteor template as suggested in this answer as it will automatically bring in the minified CSS, etc... that the dynamic pages use.

Is there a way I can setup the public folder (and all its subfolders) so that it serves index.html? This way http://app.com/ will load public/index.html?

like image 521
gozmike Avatar asked May 26 '14 13:05

gozmike


1 Answers

You could use the private folder instead and then use Assets.getText to load the contents of the file, then serve it with a server-side router from iron-router.

So off the top of my head the code would look something like this:

if (Meteor.isServer) {
  Router.map(function() {
    this.route('serverRoute', {
      path: '/',
      where: 'server',
      action: function() {
        var contents = Assets.getText('index.html');
        this.response.end(contents);
      }
    });
  });
}
like image 198
Rahul Avatar answered Nov 15 '22 10:11

Rahul