Skip to content

[browser] WasmAppHost should not force COOP/COEP when not using threading #109937

@jeromelaban

Description

@jeromelaban

Description

When running an app using the WasmAppHost, the server forces COOP/COEP:

if (options.WebServerUseCrossOriginPolicy)
{
app.Use((context, next) =>
{
context.Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
context.Response.Headers.Append("Cross-Origin-Opener-Policy", "same-origin");
return next();
});
}

This causes issues for apps that don't need this particular feature.

Reproduction Steps

Create an browser wasm app, then add a img that references a non-compatible image.

Expected behavior

The image displays when starting the app from VS.

Actual behavior

net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep 200 (OK)

Regression?

Not sure.

Known Workarounds

None, since the headers are set unconditionally:

private static WebServerOptions CreateWebServerOptions(string[] urls, string appPath, Func<WebSocket, Task>? onConsoleConnected) => new
(
OnConsoleConnected: onConsoleConnected,
ContentRootPath: Path.GetFullPath(appPath),
WebServerUseCors: true,
WebServerUseCrossOriginPolicy: true,
Urls: urls
);

Configuration

9.0.100

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions