Search code examples
meteorroutesiron-router

Metor allowing access to the public images folder for a cdn - router


I am trying to allow my images and css to be accessed by a CDN, I think the path us being hijacked by my router.

Router.route('/:permalink', function () {
  this.render('item', {
      // path: '/:permalink',
    data: function(){
        var permalinkVar = this.params.permalink;

        return Items.findOne({permalink: permalinkVar});
      },
    });

});

Is there a way to make some paths like /images /css and /js exempt from this route?


Solution

  • Put anything that you want to be exposed publicly into the public folder. From the meteor docs (http://docs.meteor.com/#/full/structuringyourapp):

    public

    All files inside a top-level directory called public are served as-is to the client. When referencing these assets, do not include public/ in the URL, write the URL as if they were all in the top level. For example, reference public/bg.png as <img src='/bg.png' />. This is the best place for favicon.ico, robots.txt, and similar files.

    So if you have an image at /public/images/image1.png, it can be accessed at yourdomain/images/image1.png.