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 -
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