Skip to content

Commit

Permalink
codeorigin: add Cross-Origin-Resource-Policy header (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil authored Jul 2, 2024
1 parent 9396ac2 commit ea06bd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/profile/templates/codeorigin/site.nginx.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ server {
# responses during revalidation or downtime. Currently 1 year, and 7 days.
add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=604800";
add_header Access-Control-Allow-Origin *;

# Allow users to opt in to Cross-Origin-Embedder-Policy
# https://github.com/jquery/infrastructure-puppet/issues/7
add_header Cross-Origin-Resource-Policy "cross-origin";

# Enable GZIP compression
gzip on;
gzip_comp_level 9;
gzip_vary on;
Expand Down
7 changes: 7 additions & 0 deletions test/CodeoriginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );

Unit::testHttp( $server, '/qunit/qunit-2.0.0.css', [], [
Expand All @@ -49,6 +50,7 @@
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );

Unit::testHttp( $server, '/ui/1.10.0/themes/base/images/ui-icons_222222_256x240.png', [], [
Expand All @@ -61,6 +63,7 @@
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );

Unit::testHttp( $server, '/jquery-2.0.0.min.map', [], [
Expand All @@ -73,6 +76,7 @@
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );

// Static asset
Expand All @@ -90,6 +94,7 @@
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );

// Gzip Compression
Expand All @@ -106,6 +111,7 @@
'etag' => '"28feccc0-40464"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'cross-origin-resource-policy' => 'cross-origin',
] );

Unit::testHttp( $server, '/qunit/qunit-2.0.0.css', [
Expand All @@ -120,6 +126,7 @@
'etag' => '"28feccc0-1d20"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'cross-origin-resource-policy' => 'cross-origin',
] );

// Renamed files
Expand Down

0 comments on commit ea06bd2

Please sign in to comment.