Nodejs: launch ghost in standalone express app and serve it to main app with proxy

My setup includes two express apps. The main application gets the blog with the route / blog from the second using the request module as a proxy. Here are the relevant snippets:

Main application: app.js:

    var request = require('request');
    app.use('/blog', function(req,res) {
        var url = 'http://localhost:8082'+require('url').parse(req.url).path;
        req.pipe(request(url)).pipe(res);
    });

      

The Ghost app is configured to run in the directory:

app.js:

    ghost().then(function (ghostServer) {
    ghostServer.start();
    });

      

config.js:

    url: 'http://localhost:8082/blog'

      

Everything seems to be working fine, but I cannot log into the admin console. Checking network requests shows that all POST requests are pending and ultimately fail. Once it fails, I get this in both applications:

POST /blog/ghost/api/v0.1/authentication/token - - ms - -

      

I tried different proxy modules but they all give the same results. I found some information on pending POST results here AngularJS + ExpressJS. A proxy POST request expects , but the setup is slightly different. Help would be really appreciated, thanks!

+3


source to share





All Articles