Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules
1 change: 1 addition & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT = 3000
1 change: 1 addition & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Backend Folder
1 change: 1 addition & 0 deletions backend/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for config files like cloudinary etc
1 change: 1 addition & 0 deletions backend/controllers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Controller Business Logic for each route
21 changes: 21 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const express = require('express');
const cookieParser = require('cookie-parser');
const cors = require('cors');
const bodyParser = require('body-parser');

require('dotenv').config();//only uploading the public env file

const app = express();
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(cors({
origin : '*'
}))
Comment on lines +12 to +14
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using wildcard '*' for CORS origin allows all domains, which poses security risks in production. Consider restricting to specific allowed origins.

Suggested change
app.use(cors({
origin : '*'
}))
// Restrict CORS origins to trusted domains from environment variable
const allowedOrigins = process.env.CORS_ORIGIN
? process.env.CORS_ORIGIN.split(',').map(origin => origin.trim())
: ['http://localhost:3000']; // fallback for development
app.use(cors({
origin: function (origin, callback) {
// allow requests with no origin (like mobile apps, curl, etc.)
if (!origin) return callback(null, true);
if (allowedOrigins.indexOf(origin) !== -1) {
return callback(null, true);
} else {
return callback(new Error('Not allowed by CORS'));
}
}
}));

Copilot uses AI. Check for mistakes.
app.get('/health',(req,res)=>{
res.send('OK');
})
const PORT = process.env.PORT || 3001;
app.listen(PORT,() => {
console.log(`Server is running on port ${PORT}`);
})
1 change: 1 addition & 0 deletions backend/models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mongo Models for data
Loading