Skip to content
Merged
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
8 changes: 5 additions & 3 deletions Backend/config/Passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ passport.use(
{
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "https://intervyo.onrender.com/api/auth/google/callback",
// callbackURL: '/api/auth/google/callback',
callbackURL: "/api/auth/google/callback",
},
async (accessToken, refreshToken, profile, done) => {
try {
Expand Down Expand Up @@ -149,12 +148,15 @@ passport.use(
// )
// );

// ========================================
// 3. GITHUB STRATEGY
// ========================================
passport.use(
new GitHubStrategy(
{
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: "https://intervyo.onrender.com/api/auth/github/callback",
callbackURL: "/api/auth/github/callback",
scope: ["user:email"],
},
async (accessToken, refreshToken, profile, done) => {
Expand Down
44 changes: 5 additions & 39 deletions Backend/config/db.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,16 @@
// db.js
import mongoose from "mongoose";
import dotenv from "dotenv";
import { MongoMemoryServer } from "mongodb-memory-server";

dotenv.config();

let mongoServer = null;

export const dbConnect = async () => {
try {
const mongoURI = process.env.MONGODB_URL || process.env.MONGODB_URI;

// Try to connect to real MongoDB if URI is provided and not default
if (mongoURI && mongoURI !== "mongodb://localhost:27017/intervyo") {
await mongoose.connect(mongoURI, {
serverSelectionTimeoutMS: 5000, // Timeout after 5s
});
console.log("βœ… MongoDB connected successfully");
return;
} else {
throw new Error("No valid MongoDB URI, using in-memory database");
}
await mongoose.connect(process.env.MONGODB_URI);
console.log("βœ… Connected to MongoDB");
} catch (error) {
console.log("⚠️ MongoDB not available:", error.message);
console.log("πŸ”„ Starting in-memory database...");

try {
// Start in-memory MongoDB server
mongoServer = await MongoMemoryServer.create({
instance: {
dbName: "intervyo",
},
});
const mongoUri = mongoServer.getUri();
await mongoose.connect(mongoUri);
console.log("βœ… In-memory MongoDB started successfully");
console.log("πŸ“ Note: Data will be lost when server restarts");
console.log("πŸ’‘ Tip: Add a real MongoDB URI to .env to persist data");
} catch (memError) {
console.error('❌ Failed to start in-memory database:', memError);
// In test environment, we might catch this at the runner level
if (process.env.NODE_ENV !== 'test') {
process.exit(1);
}
throw memError;
}
console.log("❌ Connection Failed");
console.log(error);
process.exit(1);
Comment thread
karthikc1125 marked this conversation as resolved.
}
};

Expand Down
23 changes: 0 additions & 23 deletions Backend/routes/User.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,7 @@ router.get(
}),
(req, res) => {
const token = req.user.generateAuthToken();

// res.cookie('token', token, {
// httpOnly: true,
// secure: true, // REQUIRED on HTTPS (Render + Vercel)
// sameSite: 'none', // REQUIRED for cross-domain cookies
// maxAge: 7 * 24 * 60 * 60 * 1000

// // secure: false,
// // sameSite: 'lax',
// });

// Double-whammy: Cookie AND Token in URL (Upstream req)
res.redirect(`${process.env.CLIENT_URL}/auth/callback?token=${token}`);
// res.redirect(`http://localhost:5173/auth/callback`);
},
);

Expand All @@ -61,16 +48,6 @@ router.get(
);

// GitHub OAuth Callback
// router.get('/github/callback',
// passport.authenticate('github', {
// session: false,
// failureRedirect: `${process.env.CLIENT_URL}/login?error=github_auth_failed`
// }),
// (req, res) => {
// const token = req.user.generateAuthToken();
// res.redirect(`${process.env.CLIENT_URL}/auth/callback?token=${token}`);
// }
// );
router.get(
"/github/callback",
passport.authenticate("github", {
Expand Down
15 changes: 10 additions & 5 deletions Frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ function App() {
const hideFooterRoutes = ["/login", "/register"];
const hideFooter = hideFooterRoutes.includes(location.pathname);

const hideNavbarRoutes = ["/dashboard", "/settings", "/pricing", "/career", "/terms", "/privacy", "/cookie-policy", "/interview-setup", "/auth/callback"];
const hideNavbar =
hideNavbarRoutes.includes(location.pathname) ||
location.pathname.startsWith("/interview-room");
Comment thread
karthikc1125 marked this conversation as resolved.

useEffect(() => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
}
}, []);
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
}
}, []);
Comment thread
karthikc1125 marked this conversation as resolved.

return (
<>
Expand Down Expand Up @@ -90,7 +95,7 @@ function App() {

<ScrollToTop />
<ScrollToTopOnRouteChange />
<Navbar />
{!hideNavbar && <Navbar />}

<Routes>
<Route path="/" element={<Landing />} />
Expand Down
Loading
Loading