javascript - Proxy CORS requests with grunt to localhost -


my app (http://localhost:8099) doing cors requests https://api.parse.com/ want proxy local api http://localhost:8077 testing purposes. can achived grunt-connect-proxy?

here's config of grunt-connect-proxy not work expect.

connect: {       dev: {         options: {           port: 8099,           hostname: 'localhost',           base: 'build/',           livereload: false,           keepalive: true,           middleware: function (connect, options) {             var proxy = require('grunt-connect-proxy/lib/utils').proxyrequest;             return [               // include proxy first               proxy,               // serve static files.               connect.static('build/')             ];           }         }       },       proxies: [       {         context: ['api/'], //same domain api requests, proxy works fine!         host: 'localhost',         port: 8077       },       {         context: ['api.parse.com/'], //cors, proxy not working         host: 'localhost',         port: 8077,         changeorigin: true       }]      }  → grunt serve proxy created for: api/ localhost:8077 proxy created for: api.parse.com/ localhost:8077 

so, proxying works api/ requests (same domain), ignored cors requests api.parse.com/. ideas?

when make request api.parse.com, browser connect actual parse.com server. grunt-connect-proxy comes picture when requests made application server localhost:8099 in case.

everything else other localhost:8099 remote/cross domain application (even localhost:8077) , can use grunt-connect-proxy connect these servers in server side, while on client side still make requests own server.

which server connect when proxying configured using context.

proxies: [       {         context: ['api/'],         host: 'localhost',         port: 8077       },       {         context: ['parse/'],          host: 'api.parse.com'       }] 

so, considering above configurations

localhost:8099/api --> got localhost:8077

and

localhost:8099/parse --> go api.parse.com


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -