Update index.js
Browse files
index.js
CHANGED
|
@@ -143,7 +143,8 @@ app.use((req, res, next) => {
|
|
| 143 |
|
| 144 |
// Middleware untuk mencatat detail request
|
| 145 |
app.use((req, res, next) => {
|
| 146 |
-
|
|
|
|
| 147 |
if (req.method === 'POST' || req.method === 'PUT') {
|
| 148 |
console.log('Request Body:', req.body);
|
| 149 |
}
|
|
@@ -151,6 +152,7 @@ app.use((req, res, next) => {
|
|
| 151 |
});
|
| 152 |
|
| 153 |
|
|
|
|
| 154 |
app.post('/', async (req, res) => {
|
| 155 |
const { content, user, prompt, webSearchMode } = req.body;
|
| 156 |
if (!content) {
|
|
|
|
| 143 |
|
| 144 |
// Middleware untuk mencatat detail request
|
| 145 |
app.use((req, res, next) => {
|
| 146 |
+
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
| 147 |
+
console.log(`Received ${req.method} request for ${req.url} from IP: ${ip}`);
|
| 148 |
if (req.method === 'POST' || req.method === 'PUT') {
|
| 149 |
console.log('Request Body:', req.body);
|
| 150 |
}
|
|
|
|
| 152 |
});
|
| 153 |
|
| 154 |
|
| 155 |
+
|
| 156 |
app.post('/', async (req, res) => {
|
| 157 |
const { content, user, prompt, webSearchMode } = req.body;
|
| 158 |
if (!content) {
|