5

I have a node.js application where one of the views is a ghost.js blog, which I integrated by following Ghost's wiki article Using Ghost as an npm module.

Currently, my local version works perfectly.

The Error:

When I visit the deployed website, everything works ok, except when I got to mysite.heroku.com/blog, at which point I get the ghost page looking like Ghost 404 Error Page.

I've noticed that the application has two localhost branches running simultaneusly (localhost:3000 and localhost:2368/). I'm not sure if that could be causing the error. I've checked out my Herokulogs, and they do not provide any more details than that a GET request was sent to /blog, returning first a 301and then a 404 error.

Also, it might be useful to know that when I click on the Go to front page link it sends me to http://localhost:2368/

My config.js file looks like the following:

var path = require('path'),
    config;

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://example.com/blog',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        // Change this to your Ghost blogs published URL.
        url: 'http://localhost:2368/blog',

        // Example mail config
        // Visit http://support.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        },
        paths: {
            contentPath: path.join(__dirname, '/content/')
        }
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing MySQL
    // Used by Travis - Automated testing run through GitHub
    'testing-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing pg
    // Used by Travis - Automated testing run through GitHub
    'testing-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    }
};

// Export config
module.exports = config;
maudulus
  • 10,627
  • 10
  • 78
  • 117

1 Answers1

2

It looks like Ghost is configured via a config.js file (see the link you provided), and that you may have it configured for url: 'http://localhost:2368/blog'. Looks like you'll need to change that to your actual URL.

Also, see this https://github.com/cobyism/ghost-on-heroku

Jon Mountjoy
  • 4,498
  • 22
  • 24
  • I've added what is included in my `config.js` file to the code above. – maudulus Jul 07 '15 at 23:12
  • Yep, well all those URLs in your config file are not going to work. Your app, when deployed anywhere, will never be at "localhost". Also, you should use the port that Heroku gives you (in the environment variable PORT) (which it maps to port 80 in turn), not a fixed port. Finally, you can't use SQLite - it's hardly suited to a web app in production. I recommend you follow the link to the GitHub repo I provided and check out their config. – Jon Mountjoy Jul 08 '15 at 13:07
  • I'm not sure I follow: the `localhost` parts of the config file are under `development` and `testing`, while the `production` part of the code uses a url. – maudulus Jul 09 '15 at 13:54
  • Ok fair enough. But even under production it listens on 2368 instead of $PORT. – Jon Mountjoy Jul 10 '15 at 11:46