@ayankhandelwal07/local-loop 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +19 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -49,21 +49,34 @@ socket.on("incoming-request", async (payload, callback) => {
49
49
  const { method, path, body, headers } = payload;
50
50
  console.log(chalk_1.default.blue(`📨 ${method} ${path}`));
51
51
  try {
52
- delete headers["host"];
53
- headers["host"] = `localhost:${options.port}`;
54
- delete headers["content-length"];
55
- delete headers["accept-encoding"];
52
+ const cleanHeaders = { ...headers };
53
+ Object.keys(cleanHeaders).forEach(key => {
54
+ const lowerKey = key.toLowerCase();
55
+ if (lowerKey === 'host' ||
56
+ lowerKey === 'content-length' ||
57
+ lowerKey === 'accept-encoding' ||
58
+ lowerKey === 'origin' ||
59
+ lowerKey === 'referer') {
60
+ delete cleanHeaders[key];
61
+ }
62
+ });
63
+ cleanHeaders["host"] = `localhost:${options.port}`;
56
64
  const response = await (0, axios_1.default)({
57
65
  method: method,
58
66
  url: `${LOCAL_TARGET}/${path}`,
59
- headers: headers,
67
+ headers: cleanHeaders,
60
68
  data: body,
61
69
  validateStatus: () => true
62
70
  });
63
71
  console.log(chalk_1.default.green(` ↳ Forwarded Successfully (${response.status})`));
72
+ const responseHeaders = { ...response.headers };
73
+ delete responseHeaders["content-length"];
74
+ delete responseHeaders["transfer-encoding"];
75
+ delete responseHeaders["content-encoding"];
76
+ delete responseHeaders["connection"];
64
77
  const responseToProxy = {
65
78
  status: response.status,
66
- headers: response.headers,
79
+ headers: responseHeaders,
67
80
  data: response.data
68
81
  };
69
82
  callback(responseToProxy);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayankhandelwal07/local-loop",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "bin": {
5
5
  "super-loop": "dist/index.js"
6
6
  },