NestExpressApplication is strict to Content-Type json / raw / text / urlencoded

136 Views Asked by At

I am working on support SCIM protocol. The requirements of the protocol specify that the Content-Type header should be sent with application/scim+json. There is a hard-coded list of supported Content-Type in express application (json / raw / text / urlencoded) so express is removing the body from the request since the default body parser is application/json,

I can't find a way to add different Content-Type format to the supported types.

Is there a way to define which Content-Type can be supported in my application? I want this to be limited to a specific path prefix, but that's just nice to have.

Thanks!

1

There are 1 best solutions below

0
AYRM1112013 On

you can pass extra types to the express.json() middleware options to parse them as JSON. In your case, the code will be like this

app.use(express.json({ type: ["application/json", "application/scim+json"] }));