Rooni commited on
Commit
7d9059f
1 Parent(s): f7eb0d4

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +8 -1
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
- next();
 
 
 
 
 
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