-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Accessing /static/{dir} will redirect to OS relative path #1020
Comments
Can we have a sample repo for that and how to re-produce this? |
Sample repo: https://github.com/firdausramlan/static-dir-redirect You can test it here. Click /static/img link and observe the url. |
Just tested. Seeing the same issue you're seeing. I'll have a look @firdausramlan 😄 |
Yeah! This is critical. |
Indeed. Fixing a critical bug in micro right now. Having a look after. |
@timneutkens I'll add some helpful info here to ease you task :) |
@arunoda ❤️ |
@timneutkens here's the source of the problem. It redirect to the path if it find out the path is a dir. |
@timneutkens Changing our export function serveStatic (req, res, path) {
return new Promise((resolve, reject) => {
send(req, path)
.on('error', reject)
.on('directory', function() {
const err = new Error('No dir access')
err.code = 'ENOENT'
reject(err)
})
.pipe(res)
.on('finish', resolve)
})
} |
@arunoda example works totally fine 👍 added a comment to explain why we do that 😉 |
Version: 1.2.3 & 2.0.0-beta.24
Let say I have folder /static/img, accessing url http://localhost:3000/static/img will redirect to http://localhost:3000/Users/bob/myapp/static/img/ .
The text was updated successfully, but these errors were encountered: