drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
424 stars 122 forks source link

Forward all requests for specific domain? #92

Closed dziamid closed 9 years ago

dziamid commented 9 years ago

Please, bare with my understanding of proxying concept. I need to intercept all requests to specific domain and forward them to another domain. For example, my app is being served at http://localhost:8000, I have cors xhrs requests going to https://some.public.api.com that I want to forward to http://localhost:7000. Is that possible with grunt-connect-proxy or I need another tool?

I have tried setting up conxtex config like that:

proxies: [
      {
         //same domain api requests, forwards http://localhost:8000/api to http://localhost:7000
         //works as expected
        context: ['api/'],
        host: 'localhost',
        port: 7000
      },
      {
        //expect https://some.public.api.com to be forwared to http://localhost:7000
        //does not work!
        context: ['some.public.api.com/'],
        host: 'localhost',
        port: 7000,
        changeOrigin: true
      }
]

This only works for same-domain requests, not does not for cors.

ruiaraujo commented 9 years ago

This tool will not help with that.

This proxy is installed on the server, hence the requirement that it can only proxy to requests to the same domain.

For your scenario, can do it with /etc/hosts file on Linux or OS X. I don't know how to do it in Windows.