drewzboto / grunt-connect-proxy

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

Unable to mock POST request #88

Open ghost opened 9 years ago

ghost commented 9 years ago

It seems grunt-connect-proxy is not able to mock POST request. Here is the configuration in grunt - connect: { server: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. hostname: 'localhost', livereload: 35729 }, proxies: [ { context: '/com', host: 'localhost', port: 9000, https: false, changeOrigin: false, xforward: false, headers: { "x-custom-added-header": "custom-value" }, rewrite: { '^/com/cmapi/v1/search': '/com/appdata/search' } } ] } } I am using Restangular to manage RESTFul APIs. This configuration works fine with GET request -

GET Request - https://127.0.0.1:9000/com/cmapi/v1/search/suggestion Restangular - restCaller.one('com/cmapi/v1/search/suggestion').get({query:criteria})

But when I use POST request for the same, it fails to find the mock data -

POST Request - https://127.0.0.1:9000/com/cmapi/v1/search/suggestion Restangular - restCaller.one('com/cmapi/v1/search').post("suggestion", {query:criteria});

Error - "NetworkError: 404 Not Found - http://127.0.0.1:9000/com/cmapi/v1/search/suggestion"

Thanks, Yash

xyzlast commented 9 years ago

I have same problems when post action. when post call is occur, all request parameters are lost.