Skip to content
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

How to route to a new path? #54

Closed
PierBover opened this issue Jun 14, 2017 · 2 comments
Closed

How to route to a new path? #54

PierBover opened this issue Jun 14, 2017 · 2 comments
Labels
non issue Issue is not a problem or requires changes support Questions, discussions, and general support

Comments

@PierBover
Copy link

PierBover commented Jun 14, 2017

What would be the appropriate way of proxying traffic from:

domain.com/api/v3/something

to

anotherdomain.com/something

?

I'm using this but of course h2o2 is sending the complete path to anotherdomain.com.

		{
			method: '*',
			path: '/{p?}',
			handler: {
				proxy: {
					host: 'anotherdomain.com',
					passThrough: true,
					xforward: true,
					port: 443,
					protocol: 'https'
				}
			}
		}
@PierBover
Copy link
Author

Ok, I figured it out.

	{
			method: '*',
			path: '/api/v3/{p*}',
			handler: {
				proxy: {
					passThrough: true,
					xforward: true,
					mapUri: (request, callback) => {
						const URI = 'https://anotherdomain.com/' + request.params.p;
						console.log(URI);
						callback(null, URI);
					}
				}
			}
		}

@osukaa osukaa added non issue Issue is not a problem or requires changes question labels Jun 19, 2017
@Marsup Marsup added support Questions, discussions, and general support and removed question labels Sep 21, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
non issue Issue is not a problem or requires changes support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants