budibase/packages/server/src/middleware/selfhost.ts

13 lines
361 B
TypeScript

import env from "../environment"
import { BBContext } from "@budibase/types"
// if added as a middleware will stop requests unless builder is in self host mode
// or cloud is in self host
export default async (ctx: BBContext, next: any) => {
if (env.SELF_HOSTED) {
await next()
return
}
ctx.throw(400, "Endpoint unavailable in cloud hosting.")
}