Skip to content

Commit

Permalink
Deploy to Prod
Browse files Browse the repository at this point in the history
  • Loading branch information
UjjwalSaini07 committed Oct 14, 2024
1 parent 0e4ff62 commit 5b2efe7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vercel
.env
13 changes: 13 additions & 0 deletions Backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"body-parser": "^1.20.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"nodemailer": "^6.9.15"
}
Expand Down
8 changes: 6 additions & 2 deletions Backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const nodemailer = require('nodemailer');
const cors = require('cors');
const bodyParser = require('body-parser');
require("dotenv").config()

const app = express();
const PORT = 5000; // You can change the port if needed
Expand All @@ -13,8 +14,8 @@ app.use(bodyParser.json());
const transporter = nodemailer.createTransport({
service: 'gmail', // You can use another service like SendGrid or SMTP
auth: {
user: 'saini.ujjwals007@gmail.com',
pass: 'pnot bnpc cfwp wnyx',
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});

Expand Down Expand Up @@ -59,6 +60,9 @@ app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});

export default app;


// TOdo: Basic Code with only post request not having Get Request
// const express = require('express');
// const nodemailer = require('nodemailer');
Expand Down
20 changes: 14 additions & 6 deletions Backend/vercel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"version": 2,
"builds": [
{ "src": "api/**/*.js", "use": "@vercel/node" }
]
}

"version": 2,
"builds": [
{
"src": "server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/server.js"
}
]
}
5 changes: 3 additions & 2 deletions src/pages/SweetEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const EmailPusher = () => {

if (email) {
// Make POST request to send email
const response = await fetch('http://localhost:5000/send-email', { // Update the URL if needed
method: 'POST',
// const response = await fetch('http://localhost:5000/send-email', {
const response = await fetch('https://vedic-vani-backend.vercel.app/send-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
Expand Down

0 comments on commit 5b2efe7

Please sign in to comment.