Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -3,9 +3,16 @@ const proxy = require('express-http-proxy');
|
|
| 3 |
const app = express();
|
| 4 |
const targetUrl = 'https://generativelanguage.googleapis.com';
|
| 5 |
|
|
|
|
|
|
|
| 6 |
app.use('/', (req, res, next) => {
|
| 7 |
console.log(`Request to: ${req.url}`); // Выводим URL запроса в консоль
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}, proxy(targetUrl, {
|
| 10 |
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
| 11 |
// Modify the request headers if necessary
|
|
|
|
| 3 |
const app = express();
|
| 4 |
const targetUrl = 'https://generativelanguage.googleapis.com';
|
| 5 |
|
| 6 |
+
app.use(express.json()); // добавляем middleware для парсинга JSON body
|
| 7 |
+
|
| 8 |
app.use('/', (req, res, next) => {
|
| 9 |
console.log(`Request to: ${req.url}`); // Выводим URL запроса в консоль
|
| 10 |
+
console.log(`Request method: ${req.method}`); // Выводим метод запроса
|
| 11 |
+
console.log(`Request headers: ${JSON.stringify(req.headers)}`); // Выводим headers
|
| 12 |
+
if (req.method !== 'GET') {
|
| 13 |
+
console.log(`Request body: ${JSON.stringify(req.body)}`); // Выводим body, если он есть
|
| 14 |
+
}
|
| 15 |
+
next();
|
| 16 |
}, proxy(targetUrl, {
|
| 17 |
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
| 18 |
// Modify the request headers if necessary
|