restify / restify/node-restify
Restify.plugins.serverStatic option "appendRequestPath" is bugged
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
- [ X ] Used appropriate template for the issue type
- [ X ] Searched both open and closed issues for duplicates of this issue
- [ X ] Title adequately and concisely reflects the feature or the bug
Bug Report
Restify.plugins.serverStatic option "appendRequestPath" is not working properly.
Restify Version
v6.3.4
Node.js Version
v8.91
Expected behaviour
I expected appendRequestPath = false; to make it so that the request path is not appended to the file path. (As stated in the documentation at http://restify.com/docs/plugins-api/#servestatic)
Actual behaviour
The request path was appended to the file path, despite the fact that appendRequestPath was set to false.
Repro case
index.js
var restify = require('restify');
const server = restify.createServer({
name: 'myapp',
version: '1.0.0'
});
server.get('/endpoint', restify.plugins.serveStatic({
directory: __dirname, // dirname is /Users/keithlee96/testFolder/test-api
default: 'index.html',
appendRequestPath: false
}));
server.listen(9090, function(){
console.log('%s listening at %s', server.name, server.url);
});
index.html was in the same folder.
I ran the file with node index.js
When I made a get request to localhost:9090/endpoint in postman, I got the error:
{
"code": "ResourceNotFound",
"message": "/endpoint; caused by Error: ENOENT: no such file or directory, stat '/Users/keithlee96/testFolder/test-api/endpoint'"
}
Expected the targeted file path to be: '/Users/keithlee96/testFolder/test-api/index.html'
Are you willing and able to fix this?
No, I'm no familiar with typescript, so I don't know how to fix the error myself. I just want it to behave as the documentation http://restify.com/docs/plugins-api/#servestatic says it should. Any help on this would be greatly appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reproduction is in index.js and uses restify.plugins.serveStatic with appendRequestPath set to false; start by locating the serveStatic implementation and reproducing the request to /endpoint. Done means the option prevents /endpoint from being appended and resolves index.html as described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100