You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to provide an example of using the proxy handler with mapUri? I am trying to implement a /proxy route which performs a simple forward proxy to the url querystring which gets passed to the route. I thought that mapUri would do this, but am left guessing at how it works, and what the method signature is (I just didn't have time to dig into the source today but will try that tomorrow). I must be using it wrong because the literal value for the url querystring is getting returned to the client.
Example server:
var port = 9090,
Hapi = require('hapi'),
server = new Hapi.Server('localhost', port);
server.route({
method: "GET",
path: "/proxy",
handler: {
proxy: {
mapUri: function(req, cb) {
cb(req.query.url);
}
}
}
});
server.start();
Example request:
GET http://localhost:9090/proxy?url=http://www.google.com
Example response:
http://www.google.com
Expected response:
[google homepage]
The text was updated successfully, but these errors were encountered:
Right on. So with this contract change, would the mapped querystring now become an optional part of the mapped url (as opposed to being a separate parameter passed to the callback)?
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
lockbot
locked as resolved and limited conversation to collaborators
Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Would it be possible to provide an example of using the proxy handler with mapUri? I am trying to implement a /proxy route which performs a simple forward proxy to the url querystring which gets passed to the route. I thought that mapUri would do this, but am left guessing at how it works, and what the method signature is (I just didn't have time to dig into the source today but will try that tomorrow). I must be using it wrong because the literal value for the url querystring is getting returned to the client.
Example server:
Example request:
Example response:
Expected response:
The text was updated successfully, but these errors were encountered: