Daniel Qiu
Daniel Qiu

Reputation: 1561

How do I redirect to different port on same host in Meteor?

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?

Upvotes: 0

Views: 571

Answers (1)

Christian Fritz
Christian Fritz

Reputation: 21364

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("");

Upvotes: 1

Related Questions