Dev server with proxy - large JSON response causing the proxy to return only part of the json result
Hi :-)
we got an issue when we running the dev server with proxy redirection (for the REST Server) in a case the response JSON is large the response sometime cut in the middle resulting Json.parse errors in the client.
we found a workaround solution disable chrome security (in dev mode only ) and send the request to the REST Server directly not via webpack dev proxy
is it issue with the node express server ? can i adjust the server to handle large JSON response ?
// webpack dev server configuration
devServer: {
contentBase: "./src/main/",
noInfo: false,
hot: true,
proxy: {
'/pearl/*': 'http://localhost:9595/'
}
},
if need i will supply any more relevant information. 10x
Got the same issue here, accessing the rest api endpoint is fine, but through the proxy, only the initial part shows up.
Might be caused by some response headers, since I don't have the issue before upgrading from PlayFramework 2.3 to 2.5.
Its like the framework cannot handle Large JSON response. as a bypass we redirected All REST in Development mode to the Web Server.
Is this still happening with 1.15.0? Note that you might need to change '/pearl/*' to '/pearl/**'
I'm closing this issue because of inactivity. Feel free to comment, and we can always re-open it again.
If anyone ever sees truncated json with the wds proxy if may be helpful to add this header to proxy config: headers: {"Accept-Encoding": ""}
Running into the same issue; headers: { "Accept-Encoding": "" } hasn't helped...
Reliably can access the local API without issues with the response. But through the proxy, responses longer than ~200 lines of JSON get cut off and thus aren't valid & cause console errors
No ideas currently for a fix
Yay, found the fix in my case!
// Broken
devServer: {
proxy: { /* proxy mappings */ },
https: true,
// other fields
}
// Fixed:
devServer: {
proxy: { /* proxy mappings */ },
https: true,
http2: false,
// other fields
}
In my case, I noticed that in the network tab was showing that, when trying to hit my local URL directly, it was HTTP 1.1

But when trying to access the dev server endpoint, which should be proxying to that endpoint, it was HTTP 2
It appears http2 is the default for devServer, and so I needed to set to false, and I started getting the full response every time
Seems unlikely, but possibly related issue re: more consistent HTTP 2 support for devServer: #1713
Versions: angular - v1.7.9, webpack - v4.43.0, webpack-dev-server - v3.11.0
Was receiving the following error from the AngularJS $http module:
"Error: [$http:baddata] Data must be a valid JSON object. Received: ..."

Can confirm adding http2: false to devServer fixes the issue. Cheers @jackkoppa! 🍻
Here's a snippet of my webpack devServer config:
devServer: {
// ...
compress: true,
host: '0.0.0.0',
hot: true,
http2: false,
https: true,
port: 9000,
proxy: {
'/api': {
target: 'http://localhost:1337',
pathRewrite: { '^/api' : '' }
},
'/socket.io': {
target: 'http://localhost:1337',
ws: true
}
},
// ...
}