aws-solutions/fhir-works-on-aws

[Bug] POST requests to APIG are limited to 100kb payload size

Closed this issue · 1 comments

If you try to POST a document with a payload size of > 100kb you will receive an error of the form

"ERROR PayloadTooLargeError: request entity too large"

To Reproduce
Steps to reproduce the behavior:

  1. Send an HTTP POST request to the APIG endpoint of the FHIR server that has a payload size greater than 100kb

Expected behavior
The lambda should be able to handle payloads of up to 6mb, according to main router configuration

Versions (please complete the following information):
7.0.1

Additional context
Examining the generated source code shows that the urlencoded module is not parsing the '6mb' correctly and is defaulting to 100kb, see last line of code snippet.

// ../../common/temp/node_modules/.pnpm/body-parser@1.20.1/node_modules/body-parser/lib/types/urlencoded.js
var require_urlencoded = __commonJS({
  "../../common/temp/node_modules/.pnpm/body-parser@1.20.1/node_modules/body-parser/lib/types/urlencoded.js"(exports2, module2) {
    "use strict";
    var bytes = require_bytes();
    var contentType = require_content_type();
    var createError = require_http_errors();
    var debug = require_src()("body-parser:urlencoded");
    var deprecate2 = require_depd()("body-parser");
    var read = require_read();
    var typeis = require_type_is();
    module2.exports = urlencoded;
    var parsers = /* @__PURE__ */ Object.create(null);
    function urlencoded(options) {
      var opts = options || {};
      if (opts.extended === void 0) {
        deprecate2("undefined extended: provide extended option");
      }
      var extended = opts.extended !== false;
      var inflate = opts.inflate !== false;
      var limit = typeof opts.limit !== "number" ? bytes.parse(opts.limit || "100kb") : opts.limit;

Please delete this issue. It was caused by not setting the appropriate Content-Type header on the POST request, which triggered the urlencoded parser instead of the json parser.