Closed joshua-mcginnis closed 10 years ago
Fixed on our side.
How did you solve this?
I'm having the same error when serving files. More specifically, serving angular.js. (I serve the static index.html page, which calls all static files.
// Load angular and enable static files
{
method: 'GET',
path: '/',
config: {
auth: false,
handler: function (request, reply) {
reply.file('../../ng-boilerplate/build/index.html');
}
}
},
{
method: "GET",
path: "/{path*}",
config: {
auth: false,
handler: {
directory: {
path: "../../ng-boilerplate/build",
listing: false,
index: false
}
}
}
}
@Kevin-A you are getting the above error from this route code? Can you post a full example on how to reproduce your error?
Yes, with the above code, loading the default ng-boilerplate code. I'm using an old version of Hapi though (3.1.x) due to Yar not being Hapi 6 ready. This error happens when using Chrome and refreshing the page (localhost:8002/
in my case).
(Removed all excessive code)
// index.js
var Hapi = require('hapi');
var Config = require('./config');
var Routes = require('./routes');
// Create a server with a host and port
var server = Hapi.createServer(Config.server.hostname, Config.server.port, {
cors: Config.server.cors
});
//connect the routes
server.route(Routes.endpoints);
// Start the server
server.start(function() {
console.log("The server has started on port: " + server.info.port);
});
// routes.js
/**
* Contains the list of all routes, i.e. methods, paths and the config functions
* that take care of the actions
*/
exports.endpoints = [
// Load angular and enable static files
{
method: 'GET',
path: '/',
config: {
auth: false,
handler: function (request, reply) {
reply.file('../../ng-boilerplate/build/index.html');
}
}
},
{
method: "GET",
path: "/{path*}",
config: {
auth: false,
handler: {
directory: {
path: "../../ng-boilerplate/build",
listing: false,
index: false
}
}
}
}
];
Yar is on 6.x now. Can you upgrade and retry?
I'm not able to recreate the error, so it seems fixed in Hapi 6.2.x.
I'm getting this error in Hapi 6.0.2.