Не могу получить css в приложении node/express/pug

Я создаю свое первое приложение Node, используя Express и Pug (бывший Jade). Все работает нормально, за исключением того, что мои файлы css запускаются в браузере. (Ошибка 404: GET http://localhost:3000/css/syles.css)

Структура проекта:

server.js
views
    bag.pug
public
    css
      styles.css

Мой сервер js файл:

const pug = require('pug');
const path = require('path');
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

const inv = require('./api/pogoni/inventory');

// Set views path
app.set('views', path.join(__dirname, 'views'));
// Set public path
app.use(express.static(path.join(__dirname, 'public')));
// Set pug as view engine
app.set('view engine', 'pug');

// Player's index
app.get('/player', (req, res) => {
    res.render('player', {
        title: 'PLAYER Dashboard'
    });
});

// Player's bag
app.get('/bag', (req, res) => {
    inv.getInventory()
        .then((inventory) => {
            if(!inventory) {
                throw new Error('Unable to fetch inventory.');
            }
            res.render('bag', {
                title: 'PLAYER bag',
                inventory
            });
        })
        .catch((e) => {
            res.status(500, {
              error: e
            });
        });
});

// Start server
app.listen(port, () => {
    console.log(`Server is up on port ${port}`);
});

сумка.мопс

doctype html
html
    head
        meta(charset='UTF-8')
        title #{title}
        link(rel='stylesheet', href='/css/syles.css')

person nip    schedule 09.12.2016    source источник


Ответы (1)


У вас опечатка: syles вместо стилей

doctype html
html
    head
        meta(charset='UTF-8')
        title #{title}
        link(rel='stylesheet', href='/css/styles.css')
person Fredy M    schedule 09.12.2016