Skip to content

Commit af431b3

Browse files
authored
Use more CORS headers for flutter run server (flutter#152249)
Also update tests Attempt #2 of flutter#152048 cc: @cbracken
1 parent 80cc52d commit af431b3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/flutter_tools/lib/src/isolated/devfs_web.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,9 @@ class ReleaseAssetServer {
11921192
'application/octet-stream';
11931193
return shelf.Response.ok(bytes, headers: <String, String>{
11941194
'Content-Type': mimeType,
1195-
if (_needsCoopCoep && file.basename == 'index.html') ...<String, String>{
1195+
'Cross-Origin-Resource-Policy': 'cross-origin',
1196+
'Access-Control-Allow-Origin': '*',
1197+
if (_needsCoopCoep && _fileSystem.path.extension(file.path) == '.html') ...<String, String>{
11961198
'Cross-Origin-Opener-Policy': 'same-origin',
11971199
'Cross-Origin-Embedder-Policy': 'require-corp',
11981200
}

packages/flutter_tools/test/general.shard/web/web_asset_server_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void main() {
5959

6060
expect(response.headers, <String, String>{
6161
'Content-Type': 'image/png',
62+
'Cross-Origin-Resource-Policy': 'cross-origin',
63+
'Access-Control-Allow-Origin': '*',
6264
'content-length': '64',
6365
});
6466
});
@@ -79,6 +81,8 @@ void main() {
7981

8082
expect(response.headers, <String, String>{
8183
'Content-Type': 'text/javascript',
84+
'Cross-Origin-Resource-Policy': 'cross-origin',
85+
'Access-Control-Allow-Origin': '*',
8286
'content-length': '18',
8387
});
8488
});
@@ -99,6 +103,8 @@ void main() {
99103

100104
expect(response.headers, <String, String>{
101105
'Content-Type': 'text/html',
106+
'Cross-Origin-Resource-Policy': 'cross-origin',
107+
'Access-Control-Allow-Origin': '*',
102108
'content-length': '28',
103109
});
104110
});

0 commit comments

Comments
 (0)