How to render a ejs view after sending POST form data to the server?

41 views Asked by At

I am trying to create an authentication system using EJS and PG database, but I am having trouble getting the routing and rendering to work.

In my index.html I have an anchor element that points to signup.html, which works. In signup.html I have a login form, but then when I try to submit it, I get an HTTP 405 error. How do I properly set up the routing between index.html, signup.html, and app.js (where the authentication logic happens)?

index.html:

<a href="signup.html" class="auth-link">Sign Up</a>

signup.html:

<form action="/users/register" method="POST">

app.js:

app.get("/users/register", checkAuthenticated, (req, res) => {
  res.render("register.ejs");
});
0

There are 0 answers