Http-server: Error loading files from parent directory

Created on 15 Dec 2015  路  7Comments  路  Source: http-party/http-server

It's not an issue (most likely) but I have to be sure.

I have directory tree similar to:

  • project

    • bower_components

    • lib



      • lib.css



    • app

    • index.html

My http-server is running in app directory. If I try to include lib.css in my index.html I get 404 error. I suspect that it is normal behavior and http-server can't serve files from ancestor directories. Am I correct? Or is it something wrong with my setup and http-server is supposed to be able to serve such files

Most helpful comment

it's 404 - request goes to /bower_components/lib/lib.css ignoring ".." at the begining and of course it's not there.

All 7 comments

How do you include lib.css?

AFAIK, ecstatic (the lib underlying http-server) blocks requests that leave the web root.

How do you include lib.css?

 <link rel="stylesheet" href="../bower_components/lib/lib.css" /> 

why?

Can you have a look at what HTTP status code is being returned? If you get a 403 just like ecstatic's source code implies, this is the explanation.

it's 404 - request goes to /bower_components/lib/lib.css ignoring ".." at the begining and of course it's not there.

The workaround from the stackoverflow link above is NOT to access a parent directory and have your files in the same directory or child directories.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

laughinghan picture laughinghan  路  5Comments

daGaiGuanYu picture daGaiGuanYu  路  5Comments

rgladwell picture rgladwell  路  7Comments

gswebspace picture gswebspace  路  6Comments

jiyinyiyong picture jiyinyiyong  路  6Comments