response.sendfile() fails with Error: Forbidden with path includes a symlink

here’s the stack:

Error: Forbidden
at SendStream.error (/Users/jlage/Development/web/server/bootstrap/node_modules/express/node_modules/send/lib/send.js:145:16)
at SendStream.pipe (/Users/jlage/Development/web/server/bootstrap/node_modules/express/node_modules/send/lib/send.js:307:39)
at ServerResponse.res.sendfile (/Users/jlage/Development/web/server/bootstrap/node_modules/express/lib/response.js:336:8)
at module.exports.load_funds_list (/Users/jlage/Development/web/amber/controllers/ref-data.js:23:12)
at Object.oncomplete (fs.js:297:15)

Author: Fantashit

1 thought on “response.sendfile() fails with Error: Forbidden with path includes a symlink

  1. That error comes from the path containing .. (up parent directory) and you didn’t supply the root option. Try using sendfile like so:

    res.sendfile(path, {'root': '/path/to/root/directory'});

    The root option should be the directory you want to serve the files from. It is intended to prevent the path from containing things like .. so a user may get the server to serve a file outside that directory.

Comments are closed.