Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inert required #4

Closed
MortalCatalyst opened this issue Nov 24, 2015 · 1 comment
Closed

inert required #4

MortalCatalyst opened this issue Nov 24, 2015 · 1 comment

Comments

@MortalCatalyst
Copy link

Not sure you can do much about this now but I am following your hapi starter course, going well. You were using hapi 8.4 I beleive.

Anyway at time now any version that a person uses greater than 9 will need to use 'Inert' in their code to allow to serve a static file. example here https://www.npmjs.com/package/inert#examples
This was from this github issue hapijs/hapi#2682 (comment)

which means this was the code in section 2 I needed to write

var Hapi = require('hapi');
var Inert = require('inert');

var server = new Hapi.Server();

server.connection({ port: 3000});

server.ext('onRequest', function(request, reply) {
  console.log('Request received: ' + request.path);
  reply.continue();
});

server.register(Inert, function () {});

server.route({
  path: '/',
  method: 'GET',
  handler: {
    file: 'templates/index.html'
  }
});

server.start(function() {
  console.log('Listening on ' + server.info.uri);
});
ryanmurakami added a commit that referenced this issue Nov 24, 2015
@ryanmurakami
Copy link
Owner

Thanks for the issue! You're totally right, there are some breaking changes in version 9. I've added a message to the front page of this repository to address it. My best suggestion for the course is to use version 8.8.1, so all the demo code will work perfectly. Your code above also works great.

Let me know if you find anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants