Open jameswragg opened 8 years ago
can you elaborate ? I think either you wan to use static server 'Inert' module which is probably what you wan to implement for the site to provide directory base 'public' HTML like access for sub folders. Or you want to implement a separate image server in a subdomain like a either locally (which may require some form of cross subdomain authentication; I need to look into this) or in a CDN.
But this is all probably far to complex for hapijs-examples/simple-vhost. But I would welcome either a separate project under hapijs-examples providing inert functionality or to add it to this project maybe for just one of the vhosts to show the different functionalities.
P.S. I will be releasing a HTTPS(SL/TLS) vhost version of this soon as I get round to sorting multiple domain certificates.
James, Do you want to make you a member of hapijs-examples ?
You're quite right - I found that inert was the solution (I'm very new to hapi).
I used Glue's options.preRegister to register the Inert plugin:
let options = {
preRegister: function(server, next){
server.register(Inert, (err) => {
if (err) {
console.log('Failed to load inert')
}
});
}
}
Glue.compose(manifest, options, (err, server) => { ...
Then I added an assets route to my cats/index.js & dogs/index.js
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: path.resolve(__dirname, './assets'),
redirectToSlash: true,
index: true
}
}
});
I'm so new to hapi that I'm not sure I can contribute much at the moment!
yeah I am pretty new but prefer it to express. Can you implement it for dogs.com only, push it and do a pull request please :)
This example is great, thanks so much for providing! After getting this up and running I'm wondering how assets per vhost would work? e.g. a request for /images/home.png would be vhost aware - cat.com serves up a sites/cat/assets/images/home.png, dogs.com serves up sites/dogs/assets/images/home.png