File size: 935 Bytes
abed4cc 38033f0 abed4cc 38033f0 3e67929 f7eb0d4 38033f0 7d9059f 38033f0 f7eb0d4 7a9695a 38033f0 3e67929 38033f0 9a439f0 38033f0 9a439f0 38033f0 |
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 |
const express = require('express');
const axios = require('axios');
const app = express();
const PORT = process.env.PORT || 7860;
const targetUrl = 'https://geminiyufi.vercel.app/v1/chat/completions';
const apiToken = process.env.API_KEY;
app.use(express.json());
app.post('/chat', async (req, res) => {
try {
const response = await axios.post(targetUrl, req.body, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiToken}` // Добавляем токен аутентификации
}
});
res.json(response.data);
} catch (error) {
console.error('Error: ', error.response ? error.response.data : error.message);
res.status(500).send('Error: ' + (error.response ? error.response.data : error.message));
}
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
|