I am building a web app, including routes for authentication.
The Problem: When a registration succeeds I want to redirect to /login
, but also include render options. But when I render the login.ejs
the url stays /register
.
The Options: I either have to find a way to use res.render
and change the url OR use res.redirect
and also pass render variables.
This is minimal code to show my problem:
app.get("/login", (res, req) => {
res.render("login.ejs", {flag: ""})
}
app.post("/register", (res, req) => {
// registration logic
if(success) {
res.render("login.ejs", {flag: "registration_success"})
}
}