Question

authenticate with express, passport, jwt, etc

Posted April 5, 2021 435 views
Node.jsDevelopmentJavaScript

I followed this tutorial step by step: https://www.digitalocean.com/community/tutorials/api-authentication-with-json-web-tokensjwt-and-passport

When I was done, I used postman.
ipaddress/signup with the appropriate body variables

I get a 404 error. I did some other parts. I can see that the app.use(/, routes) method works. I put a hello world block in the routes.js to see if it was being reached. It worked.

router.get(’/’, function (req, res) {
res.send(‘hello world’)
});

I’m new to node.js, so I am open to user error, but I have been doing web development for some time. I have even used nodejs in other contexts. This has got to be my fourth or fifth attempt to figure out this express, router, JWT thing. I need to be able to authenticate, so I have to figure this out. I figured using digital ocean’s tutorial was a good start. Every other tutorial I have used works. But those are admin tasks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey, @larrylines it’s hard to say without seeing your routing table.
Make sure that you don’t declare any wildcard routes before your signup route.

This:

app.get("/s*", fooRoute);

would overwrite this:

app.get("/signup", signupRoute);