Grunt Connect Proxy不发送POST参数

时间:2014-08-11 13:02:07

标签: angularjs proxy gruntjs grunt-connect grunt-connect-proxy

我的应用已配置为使用grunt-connect-proxy。请求到达服务器,除了POST请求之外,一切正常。

当使用详细选项集运行grunt时,我可以看到:

Proxied request: /api/data.json -> http://myProdutionDomain.com:80/beta/api/data.json

    {
      "host": "0.0.0.0:9000",
      "connection": "keep-alive",
      "content-length": "15",
      "accept": "application/json, text/plain, */*",
      "origin": "http://0.0.0.0:9000",
      "user-agent": "Mozilla/5.0 (Macintosh; ...)",
      "content-type": "application/json;charset=UTF-8",
      "referer": "http://0.0.0.0:9000/",
      "accept-encoding": "gzip,deflate,sdch",
      "accept-language": "en",
      "cookie": "some-cookie",
    }

我的代理配置如下:

proxies: [
            {
                context: '/api',
                host: 'myProdutionDomain.com',
                changeOrigin: true,
                rewrite: {
                    '^/': '/beta/'
                }
            }
        ]

来自Angular我只是这样做:

$http.post(requestUrl, {'id': id});

也尝试过:

request = $http.post(requestUrl, {'id': id}, {'headers': {'Content-Type': 'application/x-www-form-urlencoded'}});

问题是' id' post param永远不会发送到服务器。

任何人都有这方面的经验吗?

0 个答案:

没有答案