Add configurable cors options to worker
This commit is contained in:
parent
1d5d9d8394
commit
832127d5c8
|
@ -51,6 +51,8 @@ services:
|
||||||
INTERNAL_API_KEY: ${INTERNAL_API_KEY}
|
INTERNAL_API_KEY: ${INTERNAL_API_KEY}
|
||||||
REDIS_URL: redis-service:6379
|
REDIS_URL: redis-service:6379
|
||||||
REDIS_PASSWORD: ${REDIS_PASSWORD}
|
REDIS_PASSWORD: ${REDIS_PASSWORD}
|
||||||
|
CORS_ORIGIN: ${CORS_ORIGIN}
|
||||||
|
CORS_CREDENTIALS: ${CORS_CREDENTIALS}
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/logs
|
- ./logs:/logs
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -21,6 +21,9 @@ async function init() {
|
||||||
COUCH_DB_PASSWORD: "budibase",
|
COUCH_DB_PASSWORD: "budibase",
|
||||||
// empty string is false
|
// empty string is false
|
||||||
MULTI_TENANCY: "",
|
MULTI_TENANCY: "",
|
||||||
|
// account portal cors configuration
|
||||||
|
CORS_ORIGIN: "http://localhost:3001",
|
||||||
|
CORS_CREDENTIALS: true,
|
||||||
}
|
}
|
||||||
let envFile = ""
|
let envFile = ""
|
||||||
Object.keys(envFileJson).forEach(key => {
|
Object.keys(envFileJson).forEach(key => {
|
||||||
|
|
|
@ -33,6 +33,8 @@ module.exports = {
|
||||||
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
||||||
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
||||||
SANDBOX: process.env.SANDBOX,
|
SANDBOX: process.env.SANDBOX,
|
||||||
|
CORS_ORIGIN: process.env.CORS_ORIGIN,
|
||||||
|
CORS_CREDENTIALS: process.env.CORS_CREDENTIALS,
|
||||||
_set(key, value) {
|
_set(key, value) {
|
||||||
process.env[key] = value
|
process.env[key] = value
|
||||||
module.exports[key] = value
|
module.exports[key] = value
|
||||||
|
|
|
@ -16,12 +16,14 @@ const redis = require("./utilities/redis")
|
||||||
const app = new Koa()
|
const app = new Koa()
|
||||||
|
|
||||||
// TODO: Remove this when using envoy / nginx
|
// TODO: Remove this when using envoy / nginx
|
||||||
const accountPortalCors = {
|
if (env.CORS_ORIGIN) {
|
||||||
origin: "http://localhost:3001",
|
const corsConfig = {
|
||||||
credentials: true,
|
origin: env.CORS_ORIGIN,
|
||||||
}
|
credentials: !!env.CORS_CREDENTIALS,
|
||||||
|
}
|
||||||
|
|
||||||
app.use(cors(accountPortalCors))
|
app.use(cors(corsConfig))
|
||||||
|
}
|
||||||
|
|
||||||
app.keys = ["secret", "key"]
|
app.keys = ["secret", "key"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue