Created
July 20, 2016 21:48
-
-
Save codephi/4b232f5eabb3364414b393a2becdbc3a to your computer and use it in GitHub Desktop.
Using KeystoneJs with Express-vhost to work with multiple sites on the same port.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'), | |
evh = require('express-vhost'), | |
express = require('express'), | |
server = express(); | |
/** | |
* express-vhost | |
**/ | |
server.use(evh.vhost(server.enabled('trust proxy'))); | |
server.listen(3000); //port 3000 | |
require('dotenv').config(); | |
var keystone = require('keystone'); | |
keystone.init({ | |
//Its configuration. "Host" and "port" does not work here | |
}); | |
keystone.import('models'); | |
keystone.set('locals', { | |
_: require('lodash'), | |
env: keystone.get('env'), | |
utils: keystone.utils, | |
editable: keystone.content.editable | |
}); | |
keystone.set('routes', require('./routes')); | |
keystone.set('nav', { | |
//nav setup ... | |
}); | |
/** | |
keystone.mount () will prepare everything to start the keystone. This is very important! | |
**/ | |
keystone.mount(); | |
evh.register('*.mydomain.com', keystone.app); //registers the keystone in the defined field |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment