Use more CORS headers for flutter run server (#152249)

Also update tests

Attempt #2 of #152048

cc: @cbracken
This commit is contained in:
John Ryan
2024-07-26 11:01:41 -07:00
committed by GitHub
parent 80cc52d7d1
commit af431b38d2
2 changed files with 9 additions and 1 deletions

View File

@@ -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',
}

View File

@@ -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',
});
});
@@ -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',
});
});
@@ -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',
});
});