mongodb - Email Verification Code Issue - View Not Rendering in Node.js and EJS - Stack Overflow

I'm working on a Node.js project where I am trying to implement email verification functionality.

I'm working on a Node.js project where I am trying to implement email verification functionality. I have used Express as my framework and EJS as my templating engine. I have set up a route to handle email verification and send a response page, but the EJS view is not rendering properly. Instead, I get errors or the page doesn't load as expected.

import express from 'express';
import mongoose from 'mongoose';
import 'dotenv/config';

import usersRouter from './routes/usersRouter.js';
import authRoute from './routes/authRoute.js';

const app = express();

// Middleware to parse incoming requests with JSON payloads
app.use(express.json());

// route handlers
app.use("/api", usersRouter);
app.use("/", authRoute);

// EJS 
app.set('view engine', 'ejs');
app.set('views', './views');

// MongoDB connection 
mongoose.connect(process.env.MONGODB_URI)
  .then(() => console.log('Database Connected!'))
  .catch((error) => console.error('Database connection failed:', error.message));

// Home route
app.get('/', (req, res) => {
  res.send("Welcome to the home page!");
});

const PORT = process.env.MyPort || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

and that is my output:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744249126a4565080.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信