few points to consider:
- I have a proxy server enabled on my system, its IP is 192.18.x.x:8080
- I needs to be logged in so the creds are johndoe:john_1234
- I am using geoserver which is running at port 8085 of my machine
problem:
whenever I am trying to make a get request to the url "http://localhost:8085/geoserver/rest" programmatically using NodeJS, Python, Bash and even by Curl, I am getting a 504 error
but when I am making the same request using postman, there is no error and I am getting the desired output
here is the basic code I am using:
const http = require('http');
// Proxy server details
const proxyHost = '192.168.x.x';
const proxyPort = 8080;
const proxyUsername = 'johndoe';
const proxyPassword = 'john_1234';
// Target URL you want to request
const targetUrl = 'http://localhost:8085/geoserver/rest';
// Construct the proxy authorization header
const proxyAuthHeader = `Basic ${Buffer.from(`${proxyUsername}:${proxyPassword}`).toString('base64')}`;
// Options for the HTTP request
const options = {
hostname: proxyHost,
port: proxyPort,
path: targetUrl,
method: 'GET',
headers: {
'Proxy-Authorization': proxyAuthHeader,
},
};
// Make the request through the proxy
const req = http.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.end();
why is it working fine in postman and it also gives the error of method not allowed