Update server.js
Browse files
server.js
CHANGED
@@ -1,16 +1,25 @@
|
|
1 |
const express = require('express');
|
2 |
-
const
|
|
|
3 |
const app = express();
|
4 |
-
const
|
5 |
-
|
6 |
-
app.use(
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
const express = require('express');
|
2 |
+
const axios = require('axios');
|
3 |
+
const cors = require('cors');
|
4 |
const app = express();
|
5 |
+
const PORT = process.env.PORT || 3000;
|
6 |
+
|
7 |
+
app.use(cors());
|
8 |
+
app.use(express.json());
|
9 |
+
|
10 |
+
app.post('/', async (req, res) => {
|
11 |
+
try {
|
12 |
+
const response = await axios.post('https://geminiyufi.vercel.app/v1/chat/completions', req.body, {
|
13 |
+
headers: {
|
14 |
+
'Content-Type': 'application/json'
|
15 |
+
}
|
16 |
+
});
|
17 |
+
res.json(response.data);
|
18 |
+
} catch (error) {
|
19 |
+
res.status(500).send('Error: ' + error.message);
|
20 |
+
}
|
21 |
+
});
|
22 |
+
|
23 |
+
app.listen(PORT, () => {
|
24 |
+
console.log(`Server is running on port ${PORT}`);
|
25 |
+
});
|