Unverified Commit 0699c18e authored by Jaime Blasco's avatar Jaime Blasco Committed by GitHub

[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.
parent d7d1461f
......@@ -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];
......
......@@ -752,6 +752,28 @@ void main() {
await webDevFS.destroy();
}));
test('allows frame embedding', () async {
final WebAssetServer webAssetServer = await WebAssetServer.start(
null,
'localhost',
0,
null,
true,
true,
const BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
),
false,
Uri.base,
null,
testMode: true);
expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null);
await webAssetServer.dispose();
});
}
class MockHttpServer extends Mock implements HttpServer {}
......
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