Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev server with proxy - large JSON response causing the proxy to return only part of the json result #354

Closed
eladh opened this issue Dec 22, 2015 · 8 comments
Labels

Comments

@eladh
Copy link

eladh commented Dec 22, 2015

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

@eladh eladh changed the title Dev server with proxy - handling large JSON responses Dev server with proxy - large JSON response causing the proxy to return only part of the json result Dec 22, 2015
@qdrk
Copy link

qdrk commented Apr 18, 2016

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.

@eladh
Copy link
Author

eladh commented Apr 18, 2016

Its like the framework cannot handle Large JSON response.
as a bypass we redirected All REST in Development mode to the Web Server.

@SpaceK33z
Copy link
Member

Is this still happening with 1.15.0? Note that you might need to change '/pearl/*' to '/pearl/**'

@SpaceK33z
Copy link
Member

I'm closing this issue because of inactivity. Feel free to comment, and we can always re-open it again.

@rmanuel200
Copy link

If anyone ever sees truncated json with the wds proxy if may be helpful to add this header to proxy config: headers: {"Accept-Encoding": ""}

@jackkoppa
Copy link

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

@jackkoppa
Copy link

jackkoppa commented Feb 27, 2020

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

Screen Shot 2020-02-27 at 2 48 29 PM

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

@benstaker
Copy link

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: ..."
image

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
      }
    },
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants