0

I've some css issues in my easyrtc application, Here is my physical file structure

  • project

    • login
      • css
        • style.css
      • js
        • script.css
      • login.html
      • logout.html
    • node_modules
    • static
      • server.js
      • package.json

In the server.js I've defined,

app.get('/', function(req, res, next) {
 res.redirect('/login');
});

and

app.get('/login', function(req, res, next) {
 res.sendfile('login.html', {root: './login'});
});

In my login.html I've include following link

<link rel="stylesheet" href="css/login.css" media="screen" type="text/css" />

Also I've tried with

<link rel="stylesheet" href="./login/css/login.css" media="screen" type="text/css" />

But this css file is not loading to browser, I've inspect the element. But there was an empty css file in sources. How can I fix this? What is the root of localhost:8080 my webserver running in port 8080 Although I go through the this nodejs express solution but I'm afraid can use this kind of solution for my existing project. If yes how can I add express middle-ware to load css? Help in advance. May the FOSS be with you.

Community
  • 1
  • 1
Jedi Dula
  • 63
  • 1
  • 10
  • your route terminator is just `function(req,res)`, no `next` argument since you won't be moving on to a next middleware call. That said, how are you exposing the CSS? Do you have the `login` dir marked as static so that all its content is web-visible? If not, no URL is going to ever get to it without an `app.get(...)` dedicated to it – Mike 'Pomax' Kamermans Nov 26 '14 at 01:22

1 Answers1

1

The usual server.js used with easyrtc (as supplied in the server_example directory) has a directory called static that serves as the root directory of the static files getting served. For example, if you put files called xxx.html and yyy.css in the static folder, you could reference xxx as

  http://yoursite.com/xxx.html

and inside xxx.html you could reference yyy.css in your link statements as

href="yyy.css"

or

href="/yyy.css"

Needless to say, subdirectories work as expected.

Exhausted
  • 1,867
  • 2
  • 23
  • 33
Eric Davies
  • 78
  • 1
  • 9
  • Thank you very much @Eric I've put those file in static directory and it's work. But You gave the answer with reasons. Thanks again... – Jedi Dula Dec 05 '14 at 19:13