Grunt Connect Proxy: 404 Not Found
not directly answering your question but providing a solution (since noone else has answered) ... have you tried the npm module connect-modrewrite
this does exactly what you are trying to do.
I was having the same issue i resolve this way and its work for me. Look into my code below:-
connect: { server: { options: { keepalive: true, port: 8001, protocol: 'http', hostname: '*', directory: 'dist', open: { target: 'http://localhost:8001/myDemo.html', }, middleware: function(connect, options, middlewares) { middlewares.unshift(function(req, res, next) { res.setHeader('Access-Control-Allow-Credentials', true); res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); **if (req.method.toUpperCase() == 'POST') req.method='GET';** return next(); }); return middlewares; } } } },
see the star marked line ie if (req.method.toUpperCase() == 'POST') req.method='GET'; i done this trick and its worked for me. This aricle also helps to me https://github.com/gruntjs/grunt-contrib-connect#middleware