drewzboto / grunt-connect-proxy

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

JSON Responses are corrupt if served via proxy #115

Open klopfdreh opened 9 years ago

klopfdreh commented 9 years ago

Hi,

I'm currenty encountering the problem, that via proxy some JSON responses get corrupted. If I access the proxied server directly the response is valid and everything is working.

Response-Header of proxy (port 8000):

Cache-Control no-cache,must-revalidate
Connection close
Content-Encoding UTF-8
Content-Length 14
Content-Type application/json
Date Tue, 25 Aug 2015 08:05:51 GMT
Server WildFly/8
x-powered-by Undertow/1

Response-Body:

e
{"id":"1251

Response-Header of Wildfly via direct access (port 8080)

Cache-Control no-cache,must-revalidate
Connection keep-alive
Content-Encoding UTF-8
Content-Length 14
Content-Type application/json
Date Tue, 25 Aug 2015 08:16:44 GMT
Server WildFly/8
x-powered-by Undertow/1

Response-Body

{"id":"12522"}

(id may differ, because the actual one is returned from server during the creation process)

Environment:

  "devDependencies": {
    "autoprefixer-core": "^5.2.0",
    "chai": "^3.0.0",
    "csswring": "^3.0.5",
    "grunt": "^0.4.5",
    "serve-static": "^1.10.0", 
    "serve-index": "^1.7.2",
    "eventemitter3": "^1.1.1",
    "livereload-js": "^2.2.2",
    "connect-static": "^1.5.1",
    "connect": "^3.4.0",
    "grunt-bower-install": "^1.6.0",
    "grunt-concurrent": "^1.0.0",
    "grunt-connect-proxy": "^0.2.0",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-compass": "^1.0.3",
    "grunt-contrib-concat": "^0.5.1",
    "grunt-contrib-connect": "^0.11.2",
    "grunt-contrib-copy": "^0.8.0",
    "grunt-contrib-cssmin": "^0.12.3",
    "grunt-contrib-htmlmin": "^0.4.0",
    "grunt-contrib-jshint": "^0.11.2",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-uglify": "^0.9.1",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-file-append": "0.0.6",
    "grunt-grunt": "^0.2.3",
    "grunt-karma": "^0.11.0",
    "grunt-manifest": "^0.4.0",
    "grunt-mocha-test": "^0.12.7",
    "grunt-newer": "^1.1.0",
    "grunt-ng-annotate": "^1.0.1",
    "grunt-ng-constant": "^1.1.0",
    "grunt-postcss": "^0.4.0",
    "grunt-processhtml": "^0.3.7",
    "grunt-proxy": "^0.0.3",
    "grunt-svgstore": "^0.5.0",
    "grunt-text-replace": "^0.4.0",
    "grunt-tslint": "^2.2.0-beta",
    "grunt-typescript": "^0.6.2",
    "grunt-usemin": "^3.0.0",
    "jshint-stylish": "^2.0.0",
    "karma": "^0.12.36",
    "karma-chrome-launcher": "^0.1.12",
    "karma-coverage": "^0.3.1",
    "karma-mocha": "^0.1.10",
    "karma-phantomjs-launcher": "^0.2.0",
    "karma-sinon-chai": "^0.3.0",
    "load-grunt-tasks": "^3.2.0",
    "lodash": "^3.9.3",
    "ripple-emulator": "^0.9.29",
    "sinon": "^1.14.1",
    "time-grunt": "^1.2.1",
    "tslint": "^2.2.0-beta",
    "typescript": "~1.4.1"
  }

It looks like the response was shifted somehow and the result was started at a position which is not valid.

I also tried to fix the issue as mentioned in this ticket https://github.com/drewzboto/grunt-connect-proxy/issues/73 but without success.

In livereload I already using the new modules serve-static / serve-index to push the files / directories.

Thank you in advance!

Edit forgot to mention the proxy settings:

    {
        context: [ <some context paths containing the rest resources>],
        host: 'localhost',
        port: 8080,
        https: false,
        changeOrigin: false,
        xforward: false
    }
klopfdreh commented 9 years ago

Okay I got it! I only provided the header in this ticket which I thought to be relevant for this issue, but there were others which caused the problem:

They look like:

x-webmethods-cache-control:[no-cache,must-revalidate]

Maybe the brackets are causing the issue?!

cowwoc commented 7 years ago

@klopfdreh I am willing to bet this is caused by https://github.com/drewzboto/grunt-connect-proxy/issues/73#issuecomment-100352502

klopfdreh commented 7 years ago

Hi @cowwoc - it seems so yes. 👍