Search code examples
meteoriron-router

Deploy meteor app on meteor servers thorws iron routing error


I found some similar questions but not a clear answer about this. I have a simple meteor app. Everything works fine local but when i deploy the app on meteor servers i get an iron:router error. The strange is that when i deploy the app in --debug mode works fine. Here is the templates

 <template name="navigationBar">
 </template>
 <template name="homepage">
    {{> navigationBar}}
    <div>....</div>
    {{> footer }}  
 </template>
 <template name="login">
    {{> navigationBar}}
    <div>....</div>
    {{> footer }}  
 </template>

And the routes are

Router.route('/', function () {
   this.render('homepage');
});
Router.route('/homepage');
Router.route("/login");

Solution

  • add this template

      <template name="layout">
        <div id="main" class="row-fluid">
          {{> yield}}
        </div>
    </template>
    

    The assistant {{>}} yield define a special dynamic area will automatically display corresponding to the path acts Quote from Discover Meteor

    And now just configure The layout Template

    Router.configure({
     layoutTemplate: 'layout',
     });
    

    And change the Router.rout to this.

    Router.route('/', {name: 'homepage'});
    

    It should works and its better to have the layout template, you can add stuff like "error Template" or "Waiting Template" like this, example.

     Router.configure({
      layoutTemplate: 'layout',
       notFoundTemplate: 'notFound',
     });
    

    And the html

    <template name="notFound">
    <h1> DAMN YOU ARE ON THE WRONG PLACE GO BACK TO HOME PAGE </h1>
    <a href="{{pathFor 'homepage'}}">Go main</a>
    </template>
    

    and loadingTemplate too, etc.

    Try it it should works