grunt-connect-proxy
grunt-connect-proxy copied to clipboard
Proxy not catching requests?
trafficstars
I am having issues catching requests to api/..
// The actual grunt server settings
connect : {
options : {
port : 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname : '0.0.0.0',
// hostname : 'localhost',
livereload : 35729,
useAvailablePort : true,
},
livereload : {
options: {
open : true,
base : [
'.tmp',
'<%= yeoman.app %>'
],
middleware: function (connect, options) {
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
// Setup the proxy
var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];
// Serve static files.
options.base.forEach(function(base) {
middlewares.push(connect.static(base));
});
// Make directory browse-able.
var directory = options.directory || options.base[options.base.length - 1];
middlewares.push(connect.directory(directory));
return middlewares;
}
},
},
test : {
options: {
port : 9021,
base : [
'.tmp',
'test',
'<%= yeoman.app %>'
]
}
},
dist : {
options : {
base : '<%= yeoman.dist %>'
}
},
proxies : [{
context : '/api',
host : '10.0.4.121',
port : 8443,
https : true,
changeOrigin : false,
rewrite : {
'/api' : '/evidence/api/v2/ui/'
}
}]
},
When I run grunt serve and try out some AJAX calls, they are still going to http://localhost:9000/api/etc. This is the raw header from Fiddler:
GET http://localhost:9000/api/ping/ HTTP/1.1
Host: localhost:9000
Connection: keep-alive
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Referer: http://localhost:9000/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
This might be related to my issue #69
Seems it is not finding the correct host if I dont have the host header defined... seems that it has issue with the port.