- Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathserver.js
More file actions
Latest commit
32 lines (26 loc) · 919 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (26 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
importexpressfrom"express";
importpathfrom"path";
import{fileURLToPath}from"url";
importgetGeminiResponsefrom"./api/getGeminiResponse.js";
importdotenvfrom"dotenv";
importcorsfrom"cors";
dotenv.config();
const__filename=fileURLToPath(import.meta.url);
const__dirname=path.dirname(__filename);
constapp=express();
constPORT=process.env.PORT||5174;// Changed from 5174 to 3001
app.use(cors());
app.use(express.json());
// --- API Route for Gemini (test) ---
app.use("/api/getGeminiResponse",getGeminiResponse);
// Serve built files in production
if(process.env.NODE_ENV==="production"){
constdistPath=path.join(__dirname,"dist");
app.use(express.static(distPath));
}else{
console.log("⚙️ Running in dev mode — use Vite dev server for frontend");
app.listen(PORT,()=>{
console.log(`✅ Server running on PORT: ${PORT}`);
});
}
exportdefaultapp;