gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

fix(gatsby): Proxy non-200 HTTP responses

Open jsalvata opened this issue 1 year ago • 1 comments

Transfer errors responses from the proxied server, including the status code, to the client.

Credit for the solution to dangkyokhoang, who provided it here.

Description

Documentation

Related Issues

Fixes #36589, aka #34244, aka #33333.

jsalvata avatar Sep 11 '22 13:09 jsalvata

Hi, thanks for the PR!

Linting is complaining about two things:

  564:21  error  Replace `response·=·err.response` with `(response·=·err.response)`  prettier/prettier
  564:21  error  Expected a conditional expression and instead saw an assignment     no-cond-assign

And I agree that this line here is incorrect:

if (response = err.response) {

You shouldn't do an assignment inside this expression. I think you just need to change the other line to

res.end(error.response.rawBody)

Please try that out

LekoArts avatar Sep 12 '22 06:09 LekoArts