diff --git a/src/Components/Web.JS/dist/Release/blazor.webassembly.js b/src/Components/Web.JS/dist/Release/blazor.webassembly.js index 578dbea90e4a28d2e08b6cab050c13777ce8b23d..f4eeebb6339762a6cd6ba7788a32d084e5b2c296 100644 Binary files a/src/Components/Web.JS/dist/Release/blazor.webassembly.js and b/src/Components/Web.JS/dist/Release/blazor.webassembly.js differ diff --git a/src/Components/Web.JS/src/Boot.WebAssembly.ts b/src/Components/Web.JS/src/Boot.WebAssembly.ts index 99b117ad78d50305a8571622f80946aca3f81409..b0e4546681e45ebdadcbf828c1c7226e91d36e3f 100644 --- a/src/Components/Web.JS/src/Boot.WebAssembly.ts +++ b/src/Components/Web.JS/src/Boot.WebAssembly.ts @@ -66,8 +66,11 @@ async function boot(options?: Partial<WebAssemblyStartOptions>): Promise<void> { ); }); + // Get the custom environment setting if defined + const environment = options?.environment; + // Fetch the resources and prepare the Mono runtime - const bootConfigResult = await BootConfigResult.initAsync(); + const bootConfigResult = await BootConfigResult.initAsync(environment); const [resourceLoader] = await Promise.all([ WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig, options || {}), diff --git a/src/Components/Web.JS/src/Platform/BootConfig.ts b/src/Components/Web.JS/src/Platform/BootConfig.ts index fbf88ef0925dac3da5d941119370f3f4459cf579..5ff23f860f8a06b247cbbad9092cd7ed060d6556 100644 --- a/src/Components/Web.JS/src/Platform/BootConfig.ts +++ b/src/Components/Web.JS/src/Platform/BootConfig.ts @@ -2,7 +2,7 @@ export class BootConfigResult { private constructor(public bootConfig: BootJsonData, public applicationEnvironment: string) { } - static async initAsync(): Promise<BootConfigResult> { + static async initAsync(environment?: string): Promise<BootConfigResult> { const bootConfigResponse = await fetch('_framework/blazor.boot.json', { method: 'GET', credentials: 'include', @@ -10,8 +10,8 @@ export class BootConfigResult { }); // While we can expect an ASP.NET Core hosted application to include the environment, other - // hosts may not. Assume 'Production' in the absenc of any specified value. - const applicationEnvironment = bootConfigResponse.headers.get('Blazor-Environment') || 'Production'; + // hosts may not. Assume 'Production' in the absence of any specified value. + const applicationEnvironment = environment || bootConfigResponse.headers.get('Blazor-Environment') || 'Production'; const bootConfig: BootJsonData = await bootConfigResponse.json(); return new BootConfigResult(bootConfig, applicationEnvironment); diff --git a/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts b/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts index c6710e74059f626e5b5dfc234f8b55f5988e3761..5c3dee8692cf76e724f5d3a48e0d2e4a5200deb0 100644 --- a/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts +++ b/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts @@ -9,6 +9,11 @@ export interface WebAssemblyStartOptions { * @returns A URI string or a Response promise to override the loading process, or null/undefined to allow the default loading behavior. */ loadBootResource(type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string) : string | Promise<Response> | null | undefined; + + /** + * Override built-in environment setting on start. + */ + environment?: string; } // This type doesn't have to align with anything in BootConfig.