Open sholladay opened 4 years ago
I also am seeing this error, a regression from old Hapi v16 which I'm upgrading from
_server.route( {
method: [ 'GET', 'POST' ],
path: '/examples/corpus/{param*}',
config: {
//payload: { parse: true },
//cors: true,jsonp:"callback",
},
handler: {
directory: {
path: nlib.path.join( __dirname, "../../www/corpus/" ),
listing: true,
redirectToSlash: true,
index: [ "index.html" ],
showHidden: false,
lookupCompressed: true,
defaultExtension: "html",
}
}
} );
Switching to relative path: "./www/corpus/",
works
I'm using
"@hapi/hapi": "20.2.1",
"@hapi/inert": "^6.0.4",
FYI full path works on Windows, not on Ubuntu 20.04.
Support plan
Context
What are you trying to achieve or the steps to reproduce?
Trying to serve a directory based on an absolute
path
, as shown in the example below. Using the example, visiting/
in the browser fails to render the directory listing. Visiting a subpath that is a file does work, such as/app.js
. However, subpaths that are directories also fail to render their directory listing.In the example, removing
path.resolve()
"fixes" the issue. Please note that, in my real app, I havepath
set to a function and the actual value is determined by some business logic that walks the filesystem and returns an absolute path.What was the result you got?
A 500 Internal Server Error, which seems to be caused by inert joining an absolute path with another absolute path, resulting in a path that does not exist. For some reason, this doesn't happen on subpaths that are files.
What result did you expect?
The directory listing should be shown.