Skip to content

Commit

Permalink
Merge pull request #2453 from xela1601/undocumented/env-vars-docs-fix…
Browse files Browse the repository at this point in the history
…-typo

Fixed broken local devserver due to env vars
  • Loading branch information
richardolsson authored Jan 5, 2025
2 parents ec6d48c + a8acc4a commit 4b61034
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
} from 'next';

import { AppSession } from './types';
import { getBrowserLanguage } from './locale';
import { getMessages } from './locale';
import { getBrowserLanguage, getMessages } from './locale';
import getUserMemberships from './getUserMemberships';
import requiredEnvVar from './requiredEnvVar';
import { stringToBool } from './stringUtils';
Expand All @@ -17,6 +16,7 @@ import { ApiFetch, createApiFetch } from './apiFetch';
import { ZetkinSession, ZetkinUser } from './types/zetkin';
import { hasFeature } from './featureFlags';
import { EnvVars } from 'core/env/Environment';
import { omitUndefined } from './omitUndefined';

//TODO: Create module definition and revert to import.
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down Expand Up @@ -205,15 +205,15 @@ export const scaffold =
if (hasProps(result)) {
result.props = {
...result.props,
envVars: {
envVars: omitUndefined({
FEAT_AREAS: process.env.FEAT_AREAS,
INSTANCE_OWNER_HREF: process.env.INSTANCE_OWNER_HREF,
INSTANCE_OWNER_NAME: process.env.INSTANCE_OWNER_NAME,
MUIX_LICENSE_KEY: process.env.MUIX_LICENSE_KEY,
ZETKIN_APP_DOMAIN: process.env.ZETKIN_APP_DOMAIN,
ZETKIN_GEN2_ORGANIZE_URL: process.env.ZETKIN_GEN2_ORGANZE_URL,
ZETKIN_GEN2_ORGANIZE_URL: process.env.ZETKIN_GEN2_ORGANIZE_URL,
ZETKIN_PRIVACY_POLICY_LINK: process.env.ZETKIN_PRIVACY_POLICY_LINK,
},
}),
lang,
messages,
user: ctx.user,
Expand Down
11 changes: 11 additions & 0 deletions src/utils/omitUndefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { isUndefined, omitBy } from 'lodash';

/**
* Omits properties with `undefined` values from an object.
*
* @param obj - The object to process.
* @returns A new object with all properties that have `undefined` values removed.
*/
export const omitUndefined = (
obj: Record<string, unknown>
): Record<string, unknown> => omitBy(obj, isUndefined);

0 comments on commit 4b61034

Please sign in to comment.