Skip to content
Login Authentication (NodeJS Express)
Profile icon
ObiVibKenobi

Hi! If you’re reading this, thanks!
I recently began a project that may take a while, and decided to add in a log in system. It’s pretty easy to use Repl.DB, but here’s the problem - after someone logins, and clicks a button, they get redirected. What if someone just types that link straight into the browser? I know there’s a way to stop that from happening, but how?

Thanks!

You are viewing a single comment. View All
Profile icon
EpicGamer007

pretty simple, all you gotta do,(i will be using replauth for this example),

// check request headers to make suer they are logged in if(req.get('X-Replit-User-Name') == '' || req.get('X-Replit-User-Name') == null) { //if they are not logged in res.redirect("login") } else { // they are logged in res.send("whatever page u want to send"); }

this assumes you are using express

Profile icon
EpicGamer007

If you invite me to the repl i could probably make it more clear.