Simple case: I have app1 - which is an install of ghost (site-blog.herokuapp.com
). I have app2, which is a custom express.js app (site.herokuapp.com
).
I want to serve the blog from site.herokuapp.com/blog
.
For Ghost, here's part of my config.js
production: {
url: process.env.BLOG_IDENTIFIER_URL,
fileStorage: false,
database: {
client: 'postgres',
connection: process.env.DATABASE_URL,
debug: false
},
server: {
host: '0.0.0.0',
port: process.env.PORT
}
},
BLOG_IDENTIFIER_URL
is set to site.herokuapp.com/blog
.
For the express.js app, I have the following routing (for /blog
):
router.all('*', function(req, res) {
// blog page is actually a ghost!
var blog_url = 'http://localhost:2368';
if (process.env.NODE_ENV === 'production') {
blog_url = 'http://site-blog.herokuapp.com';
}
req.headers.host = blog_url;
require('http-proxy').createProxyServer().web(req, res, { target: blog_url });
});
This works absolutely fine locally, but when I push both the repos to heroku, and try to visit site.herokuapp.com/blog
, I get just a blank page and nothing in the logs. The request fails though:
I have tried a lot of stuff, both from SO and from the rest of the visible internet. Nothing seems to work. I'm stuck here for the last 4 hours. If you have anything that might help, please please leave a comment or an answer.