My node js version is v0.12.0. I am using express. In my application, my app runs at localhost:3000 port and ghost blog app runs on port 2368. I want ghost blog to run at localhost:3000/blog. How can I do this?
server.js
var express = require('express'),http = require('http');;
var app = express();
var path = require('path');
var cookieParser = require('cookie-parser');
// load the cookie parsing middleware
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.set('views', './views');
app.set('view engine', 'ejs');
app.get('/', function(req, res){
res.render('index');
});
var ghost = require('ghost');
// existing node application
app.route({
method: 'GET',
path: '/',
handler: function(request, reply) {
reply('hello');
}
});
// proxy to ghost blog -----------------------> this part is not working
app.route({
method: 'GET',
path: '/blog/{p*}',
handler: {
proxy: {
host: '0.0.0.0',
port: '2368'
}
}
});
ghost({
config: path.join(__dirname, 'config.js')
}).then(function (ghostServer) {
ghostServer.start();
});
app.listen(3000);
Aucun commentaire:
Enregistrer un commentaire