Skip to content

Commit a3d727f

Browse files
committed
added default for cors proxy even for previously saved configs
1 parent c0e9e26 commit a3d727f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/AddAuthFromTemplateDialog/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,10 @@ const forms = {
108108
questions: [
109109
{
110110
name: "auth.proxy.corsproxy",
111+
type: "text",
111112
title: "CORS Proxy",
112113
description:
113114
"Some requests for images or APIs (like AWS S3) are blocked by browsers for security reasons, this CORs proxy will be used to enable blocked functionality when not using the desktop application.",
114-
defaultValue:
115-
// TODO this is currently deployed on @seveibar's cloudflare, it'd be
116-
// better if it was deployed on the organization's cloudflare
117-
"https://corsproxy.seve.workers.dev/corsproxy/?apiurl={URL}",
118115
},
119116
],
120117
},
@@ -131,7 +128,10 @@ export default ({ open, onClose, onSelect, onFinish, onAuthConfigured }) => {
131128
const questionIds = form.questions.map((q) => q.name)
132129
const defaults = {}
133130
for (const questionId of questionIds) {
134-
defaults[questionId] = fromConfig(questionId)
131+
const configValue = fromConfig(questionId)
132+
if (configValue !== undefined) {
133+
defaults[questionId] = configValue
134+
}
135135
}
136136
return defaults
137137
}

src/components/AppConfig/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ const configKeyNames = [
1414
"auth.cognito.storage.aws_s3.region",
1515
"auth.s3iam.access_key_id",
1616
"auth.s3iam.secret_access_key",
17+
"auth.proxy.corsproxy",
1718
"labelhelp.disabled",
1819
"labelhelp.apikey",
1920
...defaultHotkeys.map(({ id }) => `hotkeys.${id}`),
2021
]
2122

23+
const defaultAppConfig = {
24+
"auth.proxy.corsproxy":
25+
// TODO this is currently deployed on @seveibar's cloudflare, it'd be
26+
// better if it was deployed on the organization's cloudflare
27+
"https://corsproxy.seve.workers.dev/corsproxy/?apiurl={URL}",
28+
}
29+
2230
// NOTE: appConfig should not allow any nested values
2331
export const AppConfigContext = createContext({
2432
appConfig: {},
@@ -39,6 +47,9 @@ export const AppConfigProvider = ({ children }) => {
3947
if (!configKeyNames.includes(key)) {
4048
throw new Error(`Unknown config key name "${key}"`)
4149
}
50+
if (appConfig[key] === undefined) {
51+
return defaultAppConfig[key]
52+
}
4253
return appConfig[key]
4354
},
4455
setInConfig: (key, value) => {

0 commit comments

Comments
 (0)