dmc1989
@dmc1989

Как правильно задавать пути в Node?

Когда захожу на начальную, и страницу пользователя все работает, но когда пытаюсь пойти в другую директорию - ошибка. Заранее спс
// frontpage directory
    app.get('/', require('./frontpage').get);
    
    // another directories
    app.get('/edit', require('./edit').get);
    app.post('/edit', require('./edit').post);
    app.get('/messages', require('./message').get);
    
    // registration
    app.get('/registration', require('./registration').get);
    app.post('/registration', require('./registration').post);
    app.post('/registration/name', require('./registration').postName);
    app.post('/registration/avatar', upload.any(), require('./registration').postAvatar);
    app.post('/registration/about', require('./registration').postAbout);
    app.post('/registration/info', require('./registration').postInfo);
    app.post('/registration/secret', require('./registration').postSecret);
    
    // authorization
    app.get('/login', require('./login').get);
    app.post('/login', require('./login').post);
    app.get('/logout', require('./logout').get);
    
    // users
    app.get('/users', require('./users').get);
    
    // user
    app.get('/:id', require('./frontpage').user);


Подозреваю, что проблема в next()
  • Вопрос задан
  • 115 просмотров
Решения вопроса 1
dmc1989
@dmc1989 Автор вопроса
Нужно просто проверять, вызывать
app.get('/:id', require('./frontpage').user);
или нет. А то он срабатывал на любой переданной ему строке
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
26 апр. 2024, в 09:18
500 руб./в час
26 апр. 2024, в 06:46
1500 руб./в час
26 апр. 2024, в 05:31
1000 руб./за проект