fix NotAuthorized error when serving static files while directory var… #1692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pre-Submission Checklist
make prepush
Issues
Closes:
Changes
This is to resolve issue #549, so I did not create a new issue for this pull request.
The serveStatic function sets the appendRequestPath option to true by default. This works the majority of the time, but if the directory option is set to "./", then the regex test (
node-restify/lib/plugins/static.js
Line 194 in e663699
The "p", and "re" variables are not used anywhere else in this file -- only within the serve function.
I tested this solution with the following routes:
My folder structure for the tests was something along the lines of:
/
docs/
v1/
index.html
v2/
index.html
app/
firsttest.html
secondtest().html
(contains source code)
dist/
contains typescript build output
I had the first/second test routes set to serve files from the ./app directory, as they just didn't want to serve from docs (kept getting a not found event). I'm assuming that has something to do with the wild card route taking precedence for some reason.