My app (http://localhost:8099
) is doing some CORS requests to https://api.parse.com/
that I want to proxy to my local api http://localhost:8077
for testing purposes. Can this be achived with grunt-connect-proxy
?
Here's my config of grunt-connect-proxy that does not work like I 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 the 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 is not working
host: 'localhost',
port: 8077,
changeOrigin: true
}]
}
→ grunt serve
Proxy created for: api/ to localhost:8077
Proxy created for: api.parse.com/ to localhost:8077
So, basically proxying is works for api/
requests (same domain), but is completely ignored for cors requests to api.parse.com/
. Ideas?