Skip to content

Commit

Permalink
Use more CORS headers for flutter run server (flutter#152249)
Browse files Browse the repository at this point in the history
Also update tests

Attempt #2 of flutter#152048

cc: @cbracken
  • Loading branch information
johnpryan authored Jul 26, 2024
1 parent 80cc52d commit af431b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/flutter_tools/lib/src/isolated/devfs_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,9 @@ class ReleaseAssetServer {
'application/octet-stream';
return shelf.Response.ok(bytes, headers: <String, String>{
'Content-Type': mimeType,
if (_needsCoopCoep && file.basename == 'index.html') ...<String, String>{
'Cross-Origin-Resource-Policy': 'cross-origin',
'Access-Control-Allow-Origin': '*',
if (_needsCoopCoep && _fileSystem.path.extension(file.path) == '.html') ...<String, String>{
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void main() {

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

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

expect(response.headers, <String, String>{
'Content-Type': 'text/html',
'Cross-Origin-Resource-Policy': 'cross-origin',
'Access-Control-Allow-Origin': '*',
'content-length': '28',
});
});
Expand Down

0 comments on commit af431b3

Please sign in to comment.