randydev commited on
Commit
ba0cefc
·
verified ·
1 Parent(s): 4b02fd3

Update middleware/midware.js

Browse files
Files changed (1) hide show
  1. middleware/midware.js +8 -11
middleware/midware.js CHANGED
@@ -77,12 +77,6 @@ class CheckMilWare {
77
 
78
  async handle(req, res, next) {
79
  try {
80
- /*
81
- res.setHeader("Access-Control-Allow-Origin", "null");
82
- res.setHeader("Access-Control-Allow-Methods", "GET, POST");
83
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
84
- console.log(req.headers);
85
- */
86
  res.removeHeader("Link");
87
  res.removeHeader("Connection");
88
  const xForwardedFor = req.headers['x-forwarded-for'];
@@ -110,11 +104,14 @@ class CheckMilWare {
110
  await this.dbClient.AddIpisBlocked(realIP);
111
  return res.status(403).send("Access denied: IP is blocked..");
112
  }
113
- console.log(`Real IP address is: ${realIP}
114
- path method: ${req.path}
115
- method: ${req.method}
116
- header used: ${xForwardedFor ? "x-forwarded-for" : xRealIP ? "x-real-ip" : cfConnectingIP ? "cf-connecting-ip" : "req.ip"}
117
- `);
 
 
 
118
 
119
  next();
120
  } catch (error) {
 
77
 
78
  async handle(req, res, next) {
79
  try {
 
 
 
 
 
 
80
  res.removeHeader("Link");
81
  res.removeHeader("Connection");
82
  const xForwardedFor = req.headers['x-forwarded-for'];
 
104
  await this.dbClient.AddIpisBlocked(realIP);
105
  return res.status(403).send("Access denied: IP is blocked..");
106
  }
107
+ res.on("finish", function() {
108
+ console.log(`Real IP address is: ${realIP}
109
+ path method: ${req.path}
110
+ method: ${req.method}
111
+ statusCode: ${res.statusCode}
112
+ header used: ${xForwardedFor ? "x-forwarded-for" : xRealIP ? "x-real-ip" : cfConnectingIP ? "cf-connecting-ip" : "req.ip"}
113
+ `);
114
+ });
115
 
116
  next();
117
  } catch (error) {