diff --git a/src/mono/wasm/runtime/loader/blazor/BootConfig.ts b/src/mono/wasm/runtime/loader/blazor/BootConfig.ts index 2dd751cbf748e4..05defc18901352 100644 --- a/src/mono/wasm/runtime/loader/blazor/BootConfig.ts +++ b/src/mono/wasm/runtime/loader/blazor/BootConfig.ts @@ -11,7 +11,7 @@ export class BootConfigResult { private constructor(public bootConfig: BootJsonData, public applicationEnvironment: string) { } - static fromFetchResponse(bootConfigResponse: Response, bootConfig: BootJsonData, environment?: string): BootConfigResult { + static fromFetchResponse(bootConfigResponse: Response, bootConfig: BootJsonData, environment: string | undefined): BootConfigResult { const applicationEnvironment = environment || (loaderHelpers.getApplicationEnvironment && loaderHelpers.getApplicationEnvironment(bootConfigResponse)) || "Production"; bootConfig.modifiableAssemblies = bootConfigResponse.headers.get("DOTNET-MODIFIABLE-ASSEMBLIES"); bootConfig.aspnetCoreBrowserTools = bootConfigResponse.headers.get("ASPNETCORE-BROWSER-TOOLS"); diff --git a/src/mono/wasm/runtime/loader/blazor/_Integration.ts b/src/mono/wasm/runtime/loader/blazor/_Integration.ts index 22c0d65057836f..47d9af0763be79 100644 --- a/src/mono/wasm/runtime/loader/blazor/_Integration.ts +++ b/src/mono/wasm/runtime/loader/blazor/_Integration.ts @@ -14,11 +14,9 @@ import { ICUDataMode } from "../../types/blazor"; let resourceLoader: WebAssemblyResourceLoader; export async function loadBootConfig(config: MonoConfigInternal, module: DotnetModuleInternal) { - const candidateOptions = config.startupOptions ?? {}; - const environment = candidateOptions.environment; - const bootConfigPromise = BootConfigResult.initAsync(candidateOptions.loadBootResource, environment); + const bootConfigPromise = BootConfigResult.initAsync(config.startupOptions?.loadBootResource, config.applicationEnvironment); const bootConfigResult: BootConfigResult = await bootConfigPromise; - await initializeBootConfig(bootConfigResult, module, candidateOptions); + await initializeBootConfig(bootConfigResult, module, config.startupOptions); } export async function initializeBootConfig(bootConfigResult: BootConfigResult, module: DotnetModuleInternal, startupOptions?: Partial) { diff --git a/src/mono/wasm/runtime/loader/config.ts b/src/mono/wasm/runtime/loader/config.ts index 7e6b21ef4f6c31..1d09292a0c9f15 100644 --- a/src/mono/wasm/runtime/loader/config.ts +++ b/src/mono/wasm/runtime/loader/config.ts @@ -81,6 +81,8 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi } if (loaderHelpers.diagnosticTracing) console.debug("MONO_WASM: mono_wasm_load_config"); try { + loaderHelpers.config.applicationEnvironment = loaderHelpers.config.applicationEnvironment ?? loaderHelpers.config.startupOptions?.environment ?? "Production"; + if (loaderHelpers.config.startupOptions && loaderHelpers.config.startupOptions.loadBootResource) { // If we have custom loadBootResource await loadBootConfig(loaderHelpers.config, module); @@ -91,7 +93,7 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi const loadedAnyConfig: any = (await configResponse.json()) || {}; if (loadedAnyConfig.resources) { // If we found boot config schema - await initializeBootConfig(BootConfigResult.fromFetchResponse(configResponse, loadedAnyConfig as BootJsonData), module); + await initializeBootConfig(BootConfigResult.fromFetchResponse(configResponse, loadedAnyConfig as BootJsonData, loaderHelpers.config.applicationEnvironment), module, loaderHelpers.config.startupOptions); } else { // Otherwise we found mono config schema const loadedConfig = loadedAnyConfig as MonoConfigInternal;