johnpapa / lite-server

Lightweight node server
MIT License
2.31k stars 267 forks source link

Style sheets not loaded from correct location when refreshing page with more than one path in URL #96

Open SimplyGed opened 8 years ago

SimplyGed commented 8 years ago

I have noticed that when doing a page refresh for an Angular2 app with a route that is deeper than one path e.g. http://localhost:3000/customer/detail

the CSS files are not loaded. The developer tools indicate that the server is attempting to load them from the child path, instead of from the root path i.e. server uses path: http://localhost:3000/customer/detail/styles.css but the correct path should be: http://localhost:3000/styles.css

I have attached a zip file containing a small Angular2 app that exhibits the behaviour.

Repro steps

  1. Run "npm start"
  2. From the root page, refresh and notice the style sheet is loaded correctly.
  3. Change the URL to customers/2
  4. Notice the page is loaded correctly
  5. Press F5 to reload the page
  6. The style sheet is being loaded from the wrong location.

    Environment

    • lite-server version: 222
    • nodejs version: 4.4.7
    • npm version: 3.4.0
    • OS type/version: Windows 10 Enterprise ng2-lite.zip