1
0
Fork 0
mirror of synced 2024-09-28 15:21:28 +12:00
budibase/packages/server/src/middleware/selfhost.js

17 lines
517 B
JavaScript
Raw Normal View History

const env = require("../environment")
const hosting = require("../utilities/builder/hosting")
// if added as a middleware will stop requests unless builder is in self host mode
// or cloud is in self host
module.exports = async (ctx, next) => {
if (env.CLOUD && env.SELF_HOSTED) {
await next()
return
}
const hostingInfo = await hosting.getHostingInfo()
if (hostingInfo.type === hosting.HostingTypes.SELF) {
await next()
return
}
ctx.throw(400, "Endpoint unavailable in cloud hosting.")
}