rendrjs/rendr-app-template

apiProxy should handle status code 204 properly

Closed this issue · 1 comments

An API server may return "204 No Content" for PUT or DELETE request, but apiProxy ignores it and returns "200 OK" on the server side.

      // Pass through statusCode, but not if it's an i.e. 304.
      status = response.statusCode;
      if (utils.isErrorStatus(status)) {
        res.status(status);
      }
      res.json(body);

Then, on the client side, jQuery detects "parseerror" because the response has no body.
Actually, this error occurs from "304 Not Modified" too. So, I'm not sure of this comment, but workaround is here.

      // Pass through statusCode, but not if it's an i.e. 304.
      status = response.statusCode;
      if (utils.isErrorStatus(status) || +status === 204) {

However, I believe apiProxy always should pass through status code and also end-to-end headers.

Oops, this repo is not rendr's. Sorry, closing.