My app requires local auth and keeps crashing
matigrinberg
TRIALOP

2 years ago

Hi, every time i need to log in or create a new account i get back "Application failed to respond"

There should be no issue with the Port

const port = process.env.PORT || 8080;

Neither with the host

server.listen(port, "0.0.0.0", () => {

console.log(Server is running on port ${port});

});

And it's using (either way) a local strategy as below

passport.use(

new LocalStrategy(

{ usernameField: "email" },

async (email, password, done) => {

try {

const user = await User.findOne({ email });

if (!user) {

return done(null, false, { message: "Incorrect Email" });

}

const isPasswordValid = await bcrypt.compare(password, user.password);

if (!isPasswordValid) {

return done(null, false, { message: "Incorrect Password" });

}

return done(null, user);

} catch (error) {

return done(error);

}

}

)

);

// Serializer & Deserializer

passport.serializeUser((user, done) => {

done(null, user.id);

});

passport.deserializeUser(async (id, done) => {

try {

const user = await User.findById(id);

done(null, user);

} catch (err) {

done(err);

}

});

// Exports

module.exports = passport;

1 Replies

2 years ago

While not listening on 0.0.0.0 and $PORT is the most common cause of getting the "Application failed to respond" error, it is not the only cause, that message does mean what it says, your app did not respond to the request.

Check your deployment logs for any errors.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...