0
I’m following a course of Node.js with refresh tokens and in some part of the code I started getting this error and I couldn’t figure out what might be causing it. I followed the course and my requests always worked well, but there was a class where the tutor needed to modify some parts of the code and from there I started to receive the errors. I took the files from Github to see what changed and modified my code as well.
In Postman I have this error message
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /usuario</pre>
</body>
</html>
On my VS Code terminal the API is working normally.
My server.js file is
require('dotenv').config()
const app = require('./app');
const port = 3000;
require('./')
require('./database');
require('./redis/blocklist');
const routes = require('./rotas');
routes(app);
app.listen(port, () => console.log("A API está conectada!"))
My.js route code is const posts = require('./src/posts'); const usuarios = require('. /src/usuarios');
module.exports = app => {
posts.rotas(app);
usuarios.rotas(app);
};
My user-route code.js is
const usuariosControlador = require('./usuarios-controlador');
const middlewaresAutenticacao = require('./middlewares-autenticacao');
module.exports = (app) => {
app.route('/usuario/login')
app.post(middlewaresAutenticacao.local, usuariosControlador.login);
app.route('/usuario/logout')
app.get(middlewaresAutenticacao.bearer, usuariosControlador.logout);
app.route('/usuario')
app.post(usuariosControlador.adiciona)
app.get(usuariosControlador.lista);
app.route('/usuario/:id')
app.delete(middlewaresAutenticacao.bearer, usuariosControlador.deleta);
};
My code on Github is: https://github.com/Stephani0106/Seguranca-com-NodeJS
And my tutor’s course code: https://github.com/alura-cursos/blog-do-codigo-2