Skip to content

Loading…

How i can use a proxy inside? #297

Closed
celorodovalho opened this Issue · 4 comments

4 participants

@celorodovalho

I need to put a proxy listening in the URL:
http://localhost:4000/proxy/

This will received things like this:
http://localhost:4000/proxy/http://www.google.com OR
http://localhost:4000/proxy/www.google.com

How do this?
Coz i tried put to method "proxy" in Main or in the Application controller, but in routers i dont know what to do
I already tried this:
router.match('/proxy(.:format)').to('Application.proxy') OR
router.get('/proxy(.:format)').to('Application.proxy');
But not is working, everytime i try to access the URL http://localhost:4000/proxy/http://www.google.com he gives me:
/proxy/http://www.google.com not found

Someone can help me?

@Techwraith

You'll want to do something like this:

router.get('/proxy/:url').to('Main.proxy');

You'll also want to make sure that you URL encode the URL that you want to proxy before appending it to your /proxy path.

@kieran

Since you're trying to capture a URL (which includes the special character "/"), you'll need to use a "glob" in the router to match it:

router.get('/proxy/*url').to('Main.proxy')

That should cause the route to match the input, and then pass params['url'] though to Main.proxy unharmed.

See http://kieran.github.com/barista/#globs for more on "globs"

@celorodovalho

Dont work.

I tried with this, but match "http://localhost:4000/proxy/google.com" and not "http://localhost:4000/proxy/google.com.br"

router.get('/proxy/:url').to('Main.proxy');

and, match "http://localhost:4000/proxy/google/com" not "http://localhost:4000/proxy/google.com"

router.get('/proxy/*url').to('Main.proxy')

too

router.match('/proxy/:url(.:format)', {id: /\d+/, format: 'GET'}).to('Main.proxy')
router.get('/proxy/:url(/\d+/)').to('Main.proxy')

But nothing work

@celorodovalho

I did!
With

router.match( '/proxy/:path' ).to( 'Main.proxy' ).where({ path: [ /.*/ ] });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.