سؤال

I am integrating Ghost blog which runs on port 2368 into my Meteor application which runs on port 3000. Ghost is a separate instance.

In the below template file, a hyperlink in the Meteor app is pointing to the separate instance Ghost blog.

<template name="header">
    <header class="navbar">
        <div class="navbar-inner">
           <div class="top-nav">
                <div>
                    <a href="{{pathFor 'home'}}">Home</a> -                         
                    <a href="http://localhost:2368">Blog</a> - 
                </div>                                        
           </div>
        </div>
    </header>
</template>

It works on my local machine, meaning it correctly redirects to the blogging system. However it didn't work when I deployed to production, as it still pointed to the localhost.

What is the best way to detect the host name regardless it is on local or production? Is there any way to make it work through iron-router?

هل كانت مفيدة؟

المحلول

You can use Meteor.absoluteUrl([path], [options]) for that (http://docs.meteor.com/#meteor_absoluteurl).

For instance, HTML:

<a href="{{rooturl}}:2368">Blog</a>

and JS:

Template.header.rooturl = Meteor.absoluteUrl("");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top