Unverified Commit 96d68fe3 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

fix(next-core): interop non string record values in env (#49057)



### What?

Trying to close WEB-718. Since next.config can pass `Record<String, any>` for the env value, explicitly interop it.
parent 45030d62
...@@ -51,7 +51,7 @@ pub struct NextConfig { ...@@ -51,7 +51,7 @@ pub struct NextConfig {
pub config_file: Option<String>, pub config_file: Option<String>,
pub config_file_name: String, pub config_file_name: String,
pub env: IndexMap<String, String>, pub env: IndexMap<String, JsonValue>,
pub experimental: ExperimentalConfig, pub experimental: ExperimentalConfig,
pub images: ImageConfig, pub images: ImageConfig,
pub page_extensions: Vec<String>, pub page_extensions: Vec<String>,
...@@ -509,7 +509,17 @@ impl NextConfigVc { ...@@ -509,7 +509,17 @@ impl NextConfigVc {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn env(self) -> Result<EnvMapVc> { pub async fn env(self) -> Result<EnvMapVc> {
Ok(EnvMapVc::cell(self.await?.env.clone())) // The value expected for env is Record<String, String>, but config itself
// allows arbitary object (https://github.com/vercel/next.js/blob/25ba8a74b7544dfb6b30d1b67c47b9cb5360cb4e/packages/next/src/server/config-schema.ts#L203)
// then stringifies it. We do the interop here as well.
let env = self
.await?
.env
.iter()
.map(|(k, v)| (k.clone(), v.to_string()))
.collect();
Ok(EnvMapVc::cell(env))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment