Skip to content

Commit 6664f19

Browse files
committed
refactor(config): restrict platform nextConfig overrides
Assisted-by: Codex 5.3
1 parent 517dfcb commit 6664f19

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

apps/site/next.config.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ const { default: platform } = DEPLOY_TARGET
2121
? await import(`@node-core/platform-${DEPLOY_TARGET}/next.platform.config`)
2222
: await import('./next.platform.config.mjs');
2323

24+
/**
25+
* Apply only an explicit allowlist of Next.js config keys from platform
26+
* packages so critical core config (e.g. `webpack`, `turbopack`) cannot be
27+
* overridden accidentally.
28+
*/
29+
const platformNextConfigOverrides = {
30+
env: platform.nextConfig?.env,
31+
deploymentId: platform.nextConfig?.deploymentId,
32+
};
33+
2434
/** @type {import('next').NextConfig} */
2535
const nextConfig = {
2636
// Full Support of React 18 SSR and Streaming
@@ -96,7 +106,7 @@ const nextConfig = {
96106
...config,
97107
resolve: { ...resolve, alias: { ...resolve.alias, ...platform.aliases } },
98108
}),
99-
...platform.nextConfig,
109+
...platformNextConfigOverrides,
100110
};
101111

102112
const withNextIntl = createNextIntlPlugin('./i18n.tsx');
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { NextConfig } from 'next';
2+
3+
type PlatformMdxConfig = {
4+
wasm?: boolean;
5+
twoslash?: boolean;
6+
};
7+
8+
type PlatformNextConfig = {
9+
deploymentId?: string;
10+
env?: NextConfig['env'];
11+
};
12+
13+
export type PlatformConfig = {
14+
aliases?: Record<string, string>;
15+
images?: NextConfig['images'];
16+
mdx?: PlatformMdxConfig;
17+
nextConfig?: PlatformNextConfig;
18+
};
19+
20+
declare const config: PlatformConfig;
21+
22+
export default config;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { NextConfig } from 'next';
2+
3+
type PlatformMdxConfig = {
4+
wasm?: boolean;
5+
twoslash?: boolean;
6+
};
7+
8+
type PlatformNextConfig = {
9+
deploymentId?: string;
10+
env?: NextConfig['env'];
11+
};
12+
13+
export type PlatformConfig = {
14+
aliases?: Record<string, string>;
15+
images?: NextConfig['images'];
16+
mdx?: PlatformMdxConfig;
17+
nextConfig?: PlatformNextConfig;
18+
};
19+
20+
declare const config: PlatformConfig;
21+
22+
export default config;

0 commit comments

Comments
 (0)