fix: ensure myServerConfig is never undefined

This commit is contained in:
Alexis
2021-09-16 08:35:04 +09:30
parent 537a8fdd35
commit d6d1f3cf4a
2 changed files with 6 additions and 3 deletions

View File

@@ -52,8 +52,11 @@ export const myservers = () => {
// Only update these if they exist
if (file.remote) {
// Update myservers config, this is used for origin checks in graphql
myServersConfig.remote.wanaccess = file.remote.wanaccess ?? myServersConfig.remote.wanaccess;
myServersConfig.remote.wanport = file.remote.wanport ?? myServersConfig.remote.wanport;
myServersConfig.remote = {
...(myServersConfig.remote ? myServersConfig.remote : {}),
wanaccess: file.remote.wanaccess,
wanport: file.remote.wanport
};
}
try {

View File

@@ -63,7 +63,7 @@ export const origins = {
// Get myservers config
const configPath = paths.get('myservers-config')!;
export const myServersConfig = loadState<{ remote: { wanport: string; wanaccess: string } }>(configPath);
export const myServersConfig = loadState<{ remote?: { wanport?: string; wanaccess?: string } }>(configPath) ?? {};
// We use a "Set" + "array spread" to deduplicate the strings
const getAllowedOrigins = (): string[] => {