Docs/Production
Security Defaults
Alado 3.5.12 changed several defaults to close common attacks on HTTP servers, and later releases added more. This page lists each default, what it protects against and how to change it.
Request body size
Request bodies are limited to 1 MB by default. A larger body gets 413 Content Too Large and the connection is closed, so the client cannot keep streaming. A Content-Length above the limit is refused before anything is read.
initializeApplication({
serverOptions: {
port: 3000,
maxBodySizeBytes: 10 * 1024 * 1024, // 10 MB; 0 removes the limit
},
controllers: [UserController],
});When a route authenticates with a header, a query parameter or a path parameter, the body is read only after authentication and access control pass, so an unauthenticated client cannot make the server read and parse a body there. Routes without auth, and routes whose auth reads body.*, read the body first: without a limit any client could make them buffer an unbounded amount of memory. A multipart body is held once in memory (uploaded files are views into it), so the limit also bounds uploads.
A route can set its own limit (maxBodySizeBytes in its decorator options, or Context.options.maxBodySizeBytes), which replaces the server's for that route. Raise it on the upload route alone: with a large server-wide limit, any client could make every JSON route buffer as much as the largest upload.
A route that declares nothing that reads the body (no body or files fields, no allowUnknownFields, no rawBody: true) never reads it, and neither do 404 and 405 answers. Node discards such a body when it is within the limit, so the connection is kept; a larger or chunked one closes the connection after the response, so the limit holds for bodies nobody reads too.
Bodies read as text (JSON, XML, urlencoded, plain text) and multipart text fields are also refused with 413 past about 512 MB, the longest string V8 can build, even with maxBodySizeBytes: 0. Without that check, one such request would end the process.
Client IP behind a proxy
request.ip is the socket address unless you set trustProxy. The X-Forwarded-For header is written by the client unless a proxy overwrites it, so it is only read when you say how many proxies sit in front of the app.
trustProxy |
request.ip |
|---|---|
false (default) |
The socket address. X-Forwarded-For is ignored |
1, 2, … |
The address that many hops back from the socket: 1 behind one load balancer |
true |
The left-most X-Forwarded-For address (every hop is trusted) |
request.ip is always an IP address. The header is text the client can write, so an entry is only used if it is one (net.isIP): with true the left-most valid address, with a hop count the socket address when the entry at that position is not valid. Entries some proxies write with a port (203.0.113.7:51234, [2001:db8::1]:443) give the address without it. Text such as <script>… or ' OR 1=1 -- never reaches your logs or database through request.ip.
serverOptions: {
port: 3000,
trustProxy: 1, // one load balancer in front of the app
}Rate limiting
There is no limit on how many requests a client may send unless rateLimit is set (3.13.0). With it, one IP address gets a number of requests per window, for the whole API or per endpoint, and a route such as a login can have a tighter limit of its own; a request over it gets 429 before authentication and before its body is read. Behind a proxy it needs trustProxy, or every client is counted as the proxy. See Rate Limiting.
initializeApplication({
serverOptions: {
port: 3000,
trustProxy: 1,
rateLimit: { requests: 100, windowMs: 60_000 },
},
controllers: [UserController],
});Case-sensitive routes
Routes are case-sensitive: /Admin does not match a route registered as /admin. A trailing slash and repeated slashes are still ignored (/admin/ and //admin match).
Case-insensitive matching lets requests slip past a reverse proxy that blocks paths by exact match, such as nginx location /admin { deny all; }. Turn it back on only if clients rely on it:
serverOptions: {
port: 3000,
caseSensitiveRoutes: false,
}Authentication input
@withAuth fails closed: required defaults to true, so a route refuses requests without valid credentials also when required is left out. Only an explicit required: false makes authentication optional.
The value at RequestAuthentication.inputProperty is checked before the auth handler sees it: only a string is accepted, unless the route declares a validator for that field. An object from a JSON body ({ "$ne": null }) or an array from a repeated query key gets the configured auth error, and the handler is never called with it. See Authentication.
Access-control rules get the same check for an inputProperty that reads the request, written with dots or brackets (body.ownerId, body[ownerId]): an object or an array denies access before transformInputProperty or accessControlHandler see it. See Access Control.
Route registration
Mistakes that would leave a route unreachable or unprotected stop the application at startup: an access-control rule that is misspelled or checks nothing (it would allow every request), a path parameter declared twice or with a malformed name, a second route with the same method and path, a GET route on a path the OpenAPI docs serve, a second @withAuth, @accessControl or @validateProperty on the same method or property (it would replace the first one's checks), server options that would break every response or the start (a headers value with a line break, port: NaN, openApiDoc.info: null), and a @withAuth (or other route decorator) placed above @get/@post/... when the application already exists, which would otherwise be dropped. See Registration rules.
Errors and logging
Only an HttpError or a plain { statusCode, message } object thrown by a handler keeps its status and message. Any other Error answers 500 Internal Server Error, also when it carries a statusCode of its own (errors from SDKs do, next to messages naming internals): its message never reaches the client, and it is always logged. See @defineResponse. See Logging.
Response headers Node refuses (a line break in a value built from request data, an undefined value) or an invalid status code answer 500 and are logged, also for a stream body such as fs.createReadStream(): the stream is closed and the server keeps running.
A logger that fails (throws, or its async method rejects) cannot end the process either: both errors go to console.error and the request is answered. Anything else still escaping a request answers 500, or drops the connection when the response has already started.
A header set by the handler replaces a server (serverOptions.headers) or CORS header of the same name whatever the letter case, so a header is never sent twice; two Access-Control-Allow-Origin values would make browsers refuse the response.
Every response carries X-Content-Type-Options: nosniff unless a handler or the server headers option sets that header; securityHeaders: true adds HSTS, Referrer-Policy, X-Frame-Options and CSP frame-ancestors. A handler that does not answer within 60 seconds gets 503 and its connection is closed (handlerTimeoutMs), and a request body that stops arriving for 30 seconds gets 408 (bodyIdleTimeoutMs), so neither can hold a connection and its memory for long. 0 removes either limit. See Application Setup.
Access control with missing values
With compareWithProperty, access is denied when either value is missing (undefined or null), before or after transformInputProperty. Two missing values never count as a match, so an anonymous request on a route with optional auth cannot pass a check such as headers.x-tenant-id = auth.tenantId. See Access Control.
Uploaded file content
One file per field name by default: a second file under the same name gets 400 before any file object is built, so a body of thousands of tiny file parts costs nothing. File parts under names the route does not declare are skipped while parsing. More files per field take parsing: { maxFilesPerField: n }. A body may hold at most 1000 parts, text fields and files together (parsing.maxParts, 0 for no limit): more gets 400 before any field is built, so a large maxBodySizeBytes cannot be spent on hundreds of thousands of tiny fields.
A multipart body is read whole or not at all: one without a boundary, without its first delimiter or cut off before the close delimiter gets 400 Malformed multipart body, never the parts that arrived. A part's name and file name come from its Content-Disposition header only, so another header cannot rename a field. filename loses its directories (../../etc/passwd is passwd) and its control characters (line breaks, NUL, terminal escapes; also removed from field names), so a handler that joins it to a folder cannot be sent outside it; it is still the client's text, so build your own file names. See File Uploads.
The MIME type of an upload is whatever the client declares. For types with a fixed signature (image/png, image/jpeg, image/gif, image/webp, application/pdf, application/zip) the first bytes of the file must match it too, or the request gets the field's mimetypeError. Set verifyContent: false on a field to skip the check. See @fileUploadProperty.
CORS and caches
When the answer depends on the request's Origin (a list of origins, an allowedOrigin function, or '*' with allowedCredentials), every response carries Vary: Origin, also when the origin is refused, so a shared cache never serves one origin's response to another. A Vary set by your handler is kept and merged.
allowedCredentials: true with allowedOrigin: '*' sends each browser its own Origin back, since browsers refuse * with credentials. Any website can then make requests with the user's cookies and read the answers: list the origins when a cookie carries the session, or give allowedOrigin a function returning your partners' origins. With tokens or API keys, or SameSite cookies, '*' is safe. See CORS.
Swagger UI files
Swagger UI's files and the OpenAPI document (<route>/swagger.json) are served only under openApiDoc.route, so they never take over paths of your API. Only web assets from swagger-ui-dist are served. The docs are public whenever they are enabled. See OpenAPI / Swagger.
Parsers and validators
Request parsing and built-in validators run in linear time, so no input can make one request occupy the CPU:
- Multipart bodies are split without regular expressions, as bytes (no string copy of the body); header fields are read from each part's headers only. The body is held in memory that belongs to that request alone, so a handler that goes through an uploaded file's
.buffercannot reach other data. - JSON and XML bodies nested deeper than 256 levels are refused before they are built. XML error messages give a position, never a piece of the request.
validate.string().url()acceptshttp,https,wsandwssonly by default, sojavascript:ordata:URLs cannot be stored as links.validate.string().email()caps the address at 254 characters (the RFC 5321 maximum).items()checks array items one after the other without a promise per item: a 1 MB array costs a few MB, not hundreds.shape()refuses keys it does not name, so extra keys in nested objects (isAdmin: true) do not pass;number()refusesInfinity(1e999in JSON).- A compressed body or a text body in another charset gets
415instead of being read as garbage; binary types are given as bytes. - Responses carry
Content-Lengthinstead of chunked encoding, except stream bodies.
Upgrading to 3.13.0
| Version | Change | Before | Now |
|---|---|---|---|
| 3.8.6 | Access-control rule that checks nothing, has a typo or no statusCode |
Registered; every request passed (or got 500) |
Error at startup naming the rule |
| 3.8.7 | items() with a validator from build() |
A promise per item, all at once: a 1 MB array took hundreds of MB | One item after the other, stopping at the first failure |
| 3.8.8 | Error thrown by a handler with a statusCode property |
Sent to the client with its message | 500 Internal Server Error, logged. Throw HttpError or a plain { statusCode, message } |
| 3.8.9 | DTO class that extends another DTO | Parent fields ignored: not validated, stripped | Parent fields included |
| 3.8.10 | Key a shape() does not name |
Passed | Refused, unless shape(schema, { allowUnknownKeys: true }) |
| 3.8.11 | Body with a binary Content-Type |
Decoded as UTF-8 text (bytes lost) | Exact bytes in req.rawBodyBytes; req.rawBody unset |
| 3.8.11 | Compressed body, or text in a charset other than UTF-8 | 400 Invalid JSON body or garbage |
415 |
| 3.8.11 | Empty application/octet-stream body |
req.body '' |
req.body {}, req.rawBodyBytes empty |
| 3.8.12 | Handler that never answers | Connection held for good | Same by default; 503 with handlerTimeoutMs |
| 3.8.13 | Upload file name that is not ASCII | Garbled | As sent (UTF-8) |
| 3.8.14 | 1e999 (Infinity) for number() |
Accepted | Refused |
| 3.8.16 | File part Content-Type with parameters or capitals |
415; mimetype as sent |
Accepted; mimetype lower-cased without parameters |
| 3.8.17 | Number field in a urlencoded or multipart body | Always failed number() |
Converted, as query values are |
| 3.8.18 | Route such as /files/:name.json or /a/:id/b/:id |
Registered | AladoConfigurationError, INVALID_PATH_PARAMETER |
| 3.8.19 | start(cb) on a port in use |
Uncaught exception, callback not called | Callback gets the error |
| 3.8.19 | stop(cb) when not listening |
Callback not called | Called |
| 3.8.20 | allowedOrigin with a path, trailing slash or capitals; NaN limits |
Accepted (never matched; no limit) | Error at startup |
| 3.8.21 | Arrays, null and fields named type in OpenAPI response examples |
Documented wrongly | Arrays by first item, nullable, plain properties |
| 3.8.21 | Docs routes with CORS enabled | No CORS headers | Same CORS headers as the API |
| 3.8.22 | X-Content-Type-Options |
Not sent | nosniff on every response, unless set by a handler or headers |
| 3.8.23 | Text body starting with a byte order mark | 400 |
Parsed |
| 3.8.24 | Package contents | Included source maps without sources | No source maps |
| 3.8.25 | Multipart part with name="..." in a header other than Content-Disposition |
Could be renamed by it | Name and file name from Content-Disposition only |
| 3.8.26 | Upload filename with directories (../../etc/passwd, C:\Users\me\cv.pdf) |
As sent | Last segment only (passwd, cv.pdf); . and .. are '' |
| 3.8.27 | Multipart body cut off, without its first delimiter, or without a boundary |
Parts that arrived given to the handler ({} without a boundary) |
400 Malformed multipart body; an empty body is still an empty form |
| 3.8.28 | Multipart body with more than 1000 parts | Accepted | 400 Too many multipart parts, unless parsing.maxParts allows more (0 for no limit) |
| 3.8.29 | Body limit of one route | Server-wide only | maxBodySizeBytes in the route options replaces the server's for that route |
| 3.9.0 | Several strategies in @withAuth |
One RequestAuthentication |
@withAuth(a, b) either one, @withAuth([a, b]) / allOf(a, b) both; one strategy works as before |
| 3.9.1 | @withAuth alternatives that are all optional |
The first one ended the search, even without a credential | One that authenticates nobody lets the next one try; the first one's result when none authenticates |
| 3.9.2 | Handler that never answers | Connection held for good | 503 after 60 s; handlerTimeoutMs: 0 for no limit |
| 3.9.3 | Request body that stops arriving | Held until Node's requestTimeout (300 s) |
408 after 30 s without data; bodyIdleTimeoutMs: 0 for no limit |
| 3.9.4 | Security headers | X-Content-Type-Options only |
securityHeaders: true adds HSTS, Referrer-Policy, X-Frame-Options, CSP frame-ancestors; default unchanged |
| 3.9.5 | cors.allowedOrigin |
A string or a list | Also a function returning one, called for each CORS request |
| 3.9.6 | Control characters in a multipart field name or filename |
Kept | Removed |
| 3.9.7 | A second @withAuth, @accessControl, @defineRequest or @defineResponse on one method |
Replaced the first: its strategies or rules were not checked | AladoConfigurationError, DECORATOR_REPEATED |
| 3.9.8 | A second @validateProperty, @transformProperty or @documentProperty on one property; @fileUploadProperty with any of them |
Replaced the first: one validator was not run | AladoConfigurationError, DECORATOR_REPEATED |
| 3.9.9 | Access-control rule written with brackets (body[ownerId], headers[X-Api-Key]) |
Input not checked ({ "$ne": null } reached the rule); a header in brackets found only when written in lower case |
Checked and read like the dot path |
| 3.9.10 | __defineGetter__ / __defineSetter__ in query strings and XML, or with [] in a form |
Kept | Removed, as from JSON bodies |
| 3.9.11 | Several rules in @accessControl |
One list, all must pass | @accessControl(a, b) either one, @accessControl([a, b]) / allOf(a, b) both; { anyOf: [...] } in Context.accessControl; a list works as before |
| 3.9.12 | swagger-ui-dist (the docs UI) |
5.34.1 | 5.35.0 |
| 3.9.13 | Docs page title | Swagger UI |
Alado | <openApiDoc.info.title>, Alado without a title |
| 3.9.14 | headers option with a value Node refuses (a line break) or that is not a string |
Accepted; every response then failed to be written and clients saw their connection reset | Error at startup naming the header |
| 3.9.15 | openApiDoc.info that is null or an array |
Accepted (an invalid OpenAPI document) | Error at startup; option errors say openApiDoc, not documentProperty |
| 3.9.16 | port: NaN |
Accepted; start() then threw instead of calling its callback |
Error at startup |
| 3.9.18 | Handler and body idle timeouts | A timer per request (3.9.2 to 3.9.17), up to 20% slower on small routes | One coarse timer per server; a timeout fires within one tick after the limit (60 to 61 s by default) |
| 3.9.20 | Field whose validator is built with .required(), without required: true |
Optional: a request without the field passed (the validator runs only on a value that is present); documented as optional | Required: the field's error; documented as required |
| 3.9.21 | Header, query or body field without @documentProperty in the OpenAPI document |
No schema (header, query: an invalid document) or left out (body) | {} (any value); body properties keep description and example |
| 3.9.22 | OpenAPI schema of a request field | From @documentProperty only |
From its validate chain, with the keys of @documentProperty on top; @documentProperty({ schema }) optional |
| 3.10.0 | swagger-ui-dist (the docs UI) |
5.35.0 | 5.36.0 |
| 3.11.1 | stop() with requests still running |
Waited for keepAliveTimeout after each of them (5 s by default) |
Their responses carry Connection: close; stop() returns once the last is answered |
| 3.11.2 | Route context (app.get(path, context, handler)) without options.allowUnknownFields |
Error at registration, although the type has it optional | Accepted: unknown fields are stripped, as with false |
| 3.11.3 | app.head() with a handler that is not async |
Did not compile (worked at run time) | Compiles, as for the other methods |
| 3.11.4 | Handler that returns nothing, or a response without a statusCode from 100 to 999 |
500, logged as Cannot destructure property 'statusCode' or Invalid status code |
500, logged with the route and what was returned; a stream body that is not sent is closed |
3.9.19 only updates development dependencies: nothing changes for applications. 3.10.0 adds the CLI (Scaffold) and exports the InitializeApplicationOptions type; 3.10.1 and 3.10.2 fix the CLI. 3.11.0 adds disable to the HTTP decorators (Switching a route off): nothing changes for applications that do not use it. 3.12.0 adds hooks, and state (an empty object) and route to every Request: code that builds a Request object by hand, in the unit test of a handler for instance, needs state: {} to compile. 3.13.0 adds rate limiting: nothing is limited until rateLimit is set.
Rows 3.8.6, 3.8.8, 3.8.10, 3.8.18, 3.8.20, 3.8.26, 3.8.27, 3.8.28, 3.9.2, 3.9.3, 3.9.7, 3.9.8, 3.9.9, 3.9.14, 3.9.15, 3.9.16 and 3.9.20 can stop an application that started before, or change an answer clients rely on: check them first.
Upgrading to 3.8.5
| Version | Change | Before | Now |
|---|---|---|---|
| 3.8.1 | @withAuth config without required |
Optional: requests without credentials went through anonymously | Required: 401 (the configured error). Set required: false where anonymous access is intended |
| 3.8.2 | cors.allowedHeaders left out |
No request headers allowed: browsers refused every request with Content-Type: application/json or Authorization |
['Content-Type', 'Authorization'] |
| 3.8.2 | Empty CORS header lists, allowedCredentials: false |
Sent as empty headers and Access-Control-Allow-Credentials: false |
Left out |
| 3.8.3 | Several files under one field name | Kept (the last one, or all with repeatedFiles: 'array') |
400 Too many files under one field name, unless parsing.maxFilesPerField allows more |
| 3.8.3 | File parts under undeclared names | Built, then dropped | Skipped while parsing |
| 3.8.4 | Generated OpenAPI schema names that come out the same (/user-list, /user_list) |
One route's schema replaced the other's | Suffixed: GetUserList200_2 |
| 3.8.4 | entity with characters OpenAPI does not allow ('User Profile') |
Invalid document | Replaced: User_Profile |
| 3.8.5 | XML attribute repeated on one element | Last value kept | 400 Invalid XML body |
| 3.8.5 | XML reference to a character XML does not allow (�, �, ) |
Kept as written | 400 Invalid XML body |
Upgrading to 3.8.0
| Change | Before | 3.8.0 |
|---|---|---|
body / files fields (or body.* in auth, access control) on GET, HEAD, DELETE, OPTIONS |
Accepted; the body was never read, so required fields always failed | AladoConfigurationError, BODY_NOT_ALLOWED |
Route without body or files fields, allowUnknownFields or rawBody: true |
Body read and parsed (req.rawBody set, malformed JSON 400) |
Body not read: req.body is {}, req.rawBody unset. Add rawBody: true to routes that read req.rawBody |
Body nobody reads, over maxBodySizeBytes or chunked (404, 405, routes above) |
Read to the end, connection kept | Connection closed after the response |
Urlencoded or multipart text field sent twice or as key[] |
Last value, key[] kept as the name |
Array of every value; a string() field refuses it with 400 |
| Several files under one field | Last file | Last file, or an array with parsing: { repeatedFiles: 'array' } |
File part without Content-Type |
Dropped | Kept as application/octet-stream |
| Uploaded file | { stream, size, mimetype } |
Also filename |
Empty body without Content-Type |
req.body '' |
req.body missing |
OpenAPI response schema without entity |
Named by title (or undefined): routes overwrote each other |
Named after the route, e.g. GetUsersById200 |
| OpenAPI document | Invalid in several cases (no description, "undefined" media type, in: body security scheme) |
Valid OpenAPI 3.0; required body fields listed |
HEAD on the docs routes |
404 |
Same as GET, without the body |
| Request field without a validator | TypeError at startup |
Error naming the field |
cors.allowedOrigin: '*' with allowedCredentials |
Error at startup | Each browser gets its own Origin back |
'*' in an allowedOrigin list |
Not a wildcard: other origins refused | Any origin allowed |
Upgrading to 3.7.20
| Change | Before | 3.7.20 |
|---|---|---|
Header declared with capitals (X-Api-Key) in a DTO, @withAuth or @accessControl |
Never matched (the auth failed, the rule denied, a required header was always missing) | Matches in any letter case |
| Same header declared twice in different case | Accepted | AladoConfigurationError, HEADER_DECLARED_TWICE |
null sent for an optional field |
Accepted without checks | Refused unless the validator has .nullable() |
"" sent for an optional field |
Accepted without checks | Checked by the rules (email(), min(3), … refuse it) |
JSON body false, 0, "" or null |
req.body missing |
req.body is that value |
HEAD on a path with a GET route only |
405 |
GET status and headers, no body |
Allow on a 405 for a path with a GET route |
Without HEAD |
Includes HEAD |
Absolute-form target (GET http://host/items) |
404 |
Routed as /items |
Upgrading to 3.7.15
| Change | Before | 3.7.15 |
|---|---|---|
| Logger that throws, or whose async method rejects, while logging an error | Process crashed | Both errors to console.error; the request is answered |
request.ip with trustProxy and an X-Forwarded-For entry that is not an address |
The entry as sent (any text) | Only IP addresses; the socket address as fallback; a port is dropped |
Header set by the handler and by the server or CORS in another letter case (access-control-allow-origin) |
Sent twice | Sent once, with the handler's value |
Query ?a=1&a[]=2 |
a: ['2'] |
a: ['1', '2'] |
AladoServerLogger type |
Methods return void |
Methods may return a promise |
Upgrading to 3.7.11
| Change | Before | 3.7.11 |
|---|---|---|
Access-control rule whose inputProperty reads the request and gets an object or an array |
Passed to transformInputProperty / accessControlHandler |
Access denied with the rule's statusCode and message |
Auth handler throwing an error with a 4xx statusCode |
Always logged | Logged with verbose: true only; other exceptions are still always logged |
| Text body (JSON, XML, urlencoded, plain text) or multipart text field past ~512 MB | Process crashed | 413 Content Too Large |
| Stream body with a header Node refuses, or an invalid status code | Process crashed | 500, logged; the stream is closed |
number() / bigint() validator on the auth field (query.*, path.*) |
Value checked unconverted, so always refused | Converted first, as in request validation |
| Validator declared for the auth field | Ran twice per request | Runs once |
AladoServerOptions type |
cors and openApiDoc required |
Optional ({ enable: false } by default, as at runtime) |
Upgrading to 3.7.4
| Change | Before | 3.7.4 |
|---|---|---|
| Auth input that is not a string (no validator declared for the field) | Passed to the auth handler | The auth error; the handler is not called |
| Body of a route whose auth reads a header, query or path value | Read before authentication | Read after authentication and access control; refused requests never have it parsed |
| OpenAPI document | /swagger.json |
<openApiDoc.route>/swagger.json (/swagger.json only for route /) |
| Same method and path registered twice | Second route silently ignored | AladoConfigurationError, ROUTE_ALREADY_REGISTERED |
GET route on a docs path (<route>/swagger.json, a Swagger UI file) |
Silently shadowed by the docs | AladoConfigurationError, ROUTE_RESERVED_FOR_OPEN_API |
| Decorated routes | Registered in reverse order | Registered in declaration order |
required: false auth whose handler throws |
401 |
Request goes on anonymously; the error is logged |
number() / bigint() on query and path fields |
Always failed (values are strings) | The string is converted, the handler gets the number |
| XML with mixed content | Text next to child elements dropped | Kept under #text |
| XML with text before or content after the root element | Ignored | 400 Invalid XML body |
Upgrading to 3.6.18
| Change | Before | 3.6.18 |
|---|---|---|
@withAuth / @accessControl / @defineRequest / @defineResponse above the route decorator, application already created |
Silently dropped | Error at startup |
| Errors logged | Only with verbose: true |
5xx always; 4xx with verbose: true |
validate...url() |
Any protocol new URL() accepts |
http, https, ws, wss unless listed |
| Path parameters | Raw (john%20doe) |
URL-decoded (john doe); malformed encoding gets 400 |
String or Buffer body with a JSON Content-Type |
Encoded again ("{\"a\":1}") |
Sent as it is |
Request Content-Type |
Case-sensitive prefix match | Case-insensitive media type; application/*+json parsed as JSON |
Empty body with a JSON Content-Type |
400 Invalid JSON body |
{} |
| Empty multipart fields and files | Dropped | Kept |
cors.allowedCredentials with allowedOrigin '*' |
Accepted (browsers refused every response) | Error at startup |
cors.maxAge: 0 |
Sent as 86400 |
Sent as 0 |
CORS headers on body errors (400, 413) |
Missing | Sent |
Upgrading to 3.5.12
Three defaults changed. Check these before upgrading:
| Change | Before | 3.5.12 | Keep the old behaviour |
|---|---|---|---|
| Request body limit | Unlimited | 1 MB | maxBodySizeBytes: 0 |
| Route matching | Case-insensitive | Case-sensitive | caseSensitiveRoutes: false |
| Uploads with a signature type | Declared MIME type only | Content must match the declared type | verifyContent: false per field |
request.ip |
X-Forwarded-For if sent |
Socket address (always an IP address) | trustProxy: true |
compareWithProperty, both values missing |
Access granted | Access denied | — |