api-response-manager 2.5.1 → 2.5.2

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/commands/tunnel.js +18 -4
  2. package/package.json +1 -1
@@ -110,18 +110,31 @@ async function connectTunnelClient(tunnelId, subdomain, localPort) {
110
110
  // Forward request to local server
111
111
  try {
112
112
  const localUrl = `http://localhost:${localPort}${message.path}`;
113
+
114
+ // Remove problematic headers that cause issues with local server
115
+ const forwardHeaders = { ...message.headers };
116
+ delete forwardHeaders['host'];
117
+ delete forwardHeaders['connection'];
118
+ delete forwardHeaders['accept-encoding']; // Prevent compression issues
119
+
113
120
  const response = await axios({
114
121
  method: message.method.toLowerCase(),
115
122
  url: localUrl,
116
- headers: message.headers || {},
123
+ headers: forwardHeaders,
117
124
  data: message.body,
118
- validateStatus: () => true // Accept any status code
125
+ validateStatus: () => true, // Accept any status code
126
+ responseType: 'arraybuffer', // Handle binary data properly
127
+ maxRedirects: 0, // Don't follow redirects, let the client handle them
128
+ timeout: 25000 // 25 second timeout
119
129
  });
120
130
 
121
131
  // Clean up headers to avoid conflicts
122
132
  const cleanHeaders = { ...response.headers };
123
133
  delete cleanHeaders['transfer-encoding'];
124
- delete cleanHeaders['content-length'];
134
+ delete cleanHeaders['connection'];
135
+
136
+ // Convert binary data to base64 for JSON transport
137
+ const bodyBase64 = Buffer.from(response.data).toString('base64');
125
138
 
126
139
  // Send response back to tunnel server
127
140
  ws.send(JSON.stringify({
@@ -129,7 +142,8 @@ async function connectTunnelClient(tunnelId, subdomain, localPort) {
129
142
  requestId: message.requestId,
130
143
  statusCode: response.status,
131
144
  headers: cleanHeaders,
132
- body: response.data
145
+ body: bodyBase64,
146
+ encoding: 'base64'
133
147
  }));
134
148
  } catch (error) {
135
149
  console.error(chalk.red(`Error forwarding request: ${error.message}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-response-manager",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Command-line interface for API Response Manager",
5
5
  "main": "index.js",
6
6
  "bin": {