Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken local devserver due to env vars #2453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Loading