diff --git a/packages/worker/src/index.ts b/packages/worker/src/index.ts index 5084972a4c..4b35f9bafb 100644 --- a/packages/worker/src/index.ts +++ b/packages/worker/src/index.ts @@ -36,6 +36,7 @@ const { userAgent } = require("koa-useragent") import destroyable from "server-destroy" import { initPro } from "./initPro" +import { handleScimBody } from "./middleware/handleScimBody" // configure events to use the pro audit log write // can't integrate directly into backend-core due to cyclic issues @@ -55,7 +56,9 @@ const app: Application = new Koa() app.keys = ["secret", "key"] // set up top level koa middleware -app.use(koaBody({ multipart: true })) +app.use(handleScimBody) +app.use(koaBody({ multipart: true, jsonStrict: false })) + app.use(koaSession(app)) app.use(middleware.logging) app.use(logger(logging.pinoSettings())) diff --git a/packages/worker/src/middleware/handleScimBody.ts b/packages/worker/src/middleware/handleScimBody.ts new file mode 100644 index 0000000000..06a22625f3 --- /dev/null +++ b/packages/worker/src/middleware/handleScimBody.ts @@ -0,0 +1,12 @@ +import { Ctx } from "@budibase/types" + +export const handleScimBody = (ctx: Ctx, next: any) => { + var type = ctx.req.headers["content-type"] || "" + type = type.split(";")[0] + + if (type === "application/scim+json") { + ctx.req.headers["content-type"] = "application/json" + } + + next() +}