[flutter_tool] [web] Remove x-frame-options header during debug (#62115)

Currently flutter run -d web creates a server with the x-frame-options: SAMEORIGIN added by default (shelf add it's by default). This doesn't allow you to use it inside a frame.

I am trying to build an embedded simulator in vscode and it requires using an iframe.

With this PR I remove the header for debug and profile mode.
This commit is contained in:
Jaime Blasco
2020-09-03 22:33:39 +02:00
committed by GitHub
parent d7d1461f75
commit 0699c18e99
2 changed files with 28 additions and 0 deletions

View File

@@ -159,6 +159,9 @@ class WebAssetServer implements AssetReader {
address = (await InternetAddress.lookup(hostname)).first;
}
final HttpServer httpServer = await HttpServer.bind(address, port);
// Allow rendering in a iframe.
httpServer.defaultResponseHeaders.remove('x-frame-options', 'SAMEORIGIN');
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
globals.fs.file(buildInfo.packagesPath),
logger: globals.logger,
@@ -283,6 +286,9 @@ class WebAssetServer implements AssetReader {
/* late final */ Dwds dwds;
Directory entrypointCacheDirectory;
@visibleForTesting
HttpHeaders get defaultResponseHeaders => _httpServer.defaultResponseHeaders;
@visibleForTesting
Uint8List getFile(String path) => _files[path];