-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to pass query string in url target? #1323
Comments
did you have any luck? |
@valecarlos Not until now :( |
I came to the same problem, what I did is to override the req.url, like this import https from 'https';
// import url from 'url';
import path from 'path';
import fs from 'fs';
import httpProxy from 'http-proxy';
import getEnv from '@root/env';
import resolveTarget from './resolveTarget';
const env = getEnv(path);
/* eslint-disable no-sync */
const credentials = {
key: fs.readFileSync(path.join(__dirname, './certs/server.key')),
cert: fs.readFileSync(path.join(__dirname,'./certs/server.crt')),
};
const proxyServer = httpProxy.createProxyServer();
proxyServer.on('proxyError', error => {
console.log('PROXY error: ------------------------------------->', error);
});
const server = https.createServer(credentials, (req, res) => {
const target = resolveTarget({ req, env });
const query = '?company_id=co001';
const fillLength = 50 - req.url.length;
req.url = `${req.url}${query}`;
console.log(req.url, '-'.repeat(fillLength), '> target: ', target);
proxyServer.web(req, res, { target });
}, error => {
console.log('ERROR ------------------------------->', error);
});
server.listen(env.proxy.httpPort);
console.log(`PROXY listening on port ${env.proxy.httpPort}`); I hope that helps. |
I managed to get to this solution but in the end my problem got knocked up being with the hash of kibana :( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I mounted the https server with the following structure
The
https://test.com
page is normally loaded in my localhost reverse proxy but ignores the parameters passed via query string?=test
. How could I do to pass parameters in the target?The text was updated successfully, but these errors were encountered: