Skip to content

Using ".." in file path parameter of Static Middleware call #298

Closed
joefru opened this Issue Jun 18, 2011 · 6 comments

4 participants

@joefru
joefru commented Jun 18, 2011

I have my Express config nested in a folder like this: ./lib/config/config.js. When I try to do this:

app.use(express.static(__dirname + "/../../public"));

I get a Forbidden error for anything in the public folder.

When I move that use statement to a file in the root folder of my app and call it like this:

app.use(express.static(__dirname + "/public"));

it works perfectly fine. It used to work both ways before I updated Connect to 1.4.5 from 1.4.1.

@rauchg
rauchg commented Jun 18, 2011

For now you can do (in your nested config):

app.use(express.static(require('path').resolve(__dirname + "/../../public")));
@joefru
joefru commented Jun 18, 2011

Thanks, guille. Worked like a charm.

@tj
Sencha Labs member
tj commented Jun 18, 2011

fixed

@tj tj closed this Jun 18, 2011
@rauchg
rauchg commented Jun 18, 2011

Was this a 4am fix TJ?

@tj
Sencha Labs member
tj commented Jun 18, 2011

my sleeping skills are amazing, among the best, perhaps even better than mercedes

@n2liquid
n2liquid commented Nov 7, 2013

TJ, why don't you tell us more about that rm -rf pull request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.