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.

1
  • 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 Commented Nov 26, 2014 at 1:22

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.