mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 09:17:20 +00:00
Site isolation headers & redirect fix (#866)
* Fix redirect behaviour * Generate headers file * Specific redirect * Another try * And again * Use dedent
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -182,6 +182,12 @@
|
|||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/dedent": {
|
||||||
|
"version": "0.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/dedent/-/dedent-0.7.0.tgz",
|
||||||
|
"integrity": "sha512-EGlKlgMhnLt/cM4DbUSafFdrkeJoC9Mvnj0PUCU7tFmTjMjNRT957kXCx0wYm3JuEq4o4ZsS5vG+NlkM2DMd2A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/estree": {
|
"@types/estree": {
|
||||||
"version": "0.0.39",
|
"version": "0.0.39",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||||
"@rollup/plugin-replace": "^2.3.4",
|
"@rollup/plugin-replace": "^2.3.4",
|
||||||
"@surma/rollup-plugin-off-main-thread": "^1.4.2",
|
"@surma/rollup-plugin-off-main-thread": "^1.4.2",
|
||||||
|
"@types/dedent": "^0.7.0",
|
||||||
"@types/node": "^14.14.7",
|
"@types/node": "^14.14.7",
|
||||||
"comlink": "^4.3.0",
|
"comlink": "^4.3.0",
|
||||||
"cssnano": "^4.1.10",
|
"cssnano": "^4.1.10",
|
||||||
|
"dedent": "^0.7.0",
|
||||||
"del": "^5.1.0",
|
"del": "^5.1.0",
|
||||||
"file-drop-element": "^1.0.1",
|
"file-drop-element": "^1.0.1",
|
||||||
"husky": "^4.3.0",
|
"husky": "^4.3.0",
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
Cache-Control: no-cache
|
|
||||||
|
|
||||||
/c/*
|
|
||||||
Cache-Control: max-age=31536000
|
|
||||||
|
|
||||||
# COOP+COEP for WebAssembly threads.
|
|
||||||
/*
|
|
||||||
Cross-Origin-Embedder-Policy: require-corp
|
|
||||||
Cross-Origin-Opener-Policy: same-origin
|
|
||||||
# Origin trial for WebAssembly SIMD.
|
|
||||||
# ATTENTION: This one is configured for dev--squoosh.netlify.app preview.
|
|
||||||
# For production squoosh.app, replace with AgoKiDqjr0GVPtrwV/vuVlrrSvbDa5Yb99s+q66ly816DrrAQ8Cdas33NgDtmhxM4BtDP9PEdyuxHPyTQHD5ZAcAAABUeyJvcmlnaW4iOiJodHRwczovL3NxdW9vc2guYXBwOjQ0MyIsImZlYXR1cmUiOiJXZWJBc3NlbWJseVNpbWQiLCJleHBpcnkiOjE2MDg2NzI5OTR9.
|
|
||||||
Origin-Trial: As3b1fXjclhF8ZgvUkIqOo3r1/Jqvx0mNuT6Ilgb7SdpeJnV8lUdYr7i+OKgCmcVTWkqjkF23LJ+xZ111VYMEQIAAABheyJvcmlnaW4iOiJodHRwczovL2Rldi0tc3F1b29zaC5uZXRsaWZ5LmFwcDo0NDMiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlTaW1kIiwiZXhwaXJ5IjoxNjA5NDI4Nzk4fQ==
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
/index.html / 301
|
/editor / 301
|
||||||
/* /index.html 301
|
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ import { renderPage, writeFiles } from './utils';
|
|||||||
import IndexPage from './pages/index';
|
import IndexPage from './pages/index';
|
||||||
import iconLargeMaskable from 'url:static-build/assets/icon-large-maskable.png';
|
import iconLargeMaskable from 'url:static-build/assets/icon-large-maskable.png';
|
||||||
import iconLarge from 'url:static-build/assets/icon-large.png';
|
import iconLarge from 'url:static-build/assets/icon-large.png';
|
||||||
|
import dedent from 'dedent';
|
||||||
|
|
||||||
|
// Set by Netlify
|
||||||
|
const branch = process.env.BRANCH;
|
||||||
|
|
||||||
|
const branchOriginTrialIds = new Map([
|
||||||
|
[
|
||||||
|
'dev',
|
||||||
|
'As3b1fXjclhF8ZgvUkIqOo3r1/Jqvx0mNuT6Ilgb7SdpeJnV8lUdYr7i+OKgCmcVTWkqjkF23LJ+xZ111VYMEQIAAABheyJvcmlnaW4iOiJodHRwczovL2Rldi0tc3F1b29zaC5uZXRsaWZ5LmFwcDo0NDMiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlTaW1kIiwiZXhwaXJ5IjoxNjA5NDI4Nzk4fQ==',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'live',
|
||||||
|
'AgoKiDqjr0GVPtrwV/vuVlrrSvbDa5Yb99s+q66ly816DrrAQ8Cdas33NgDtmhxM4BtDP9PEdyuxHPyTQHD5ZAcAAABUeyJvcmlnaW4iOiJodHRwczovL3NxdW9vc2guYXBwOjQ0MyIsImZlYXR1cmUiOiJXZWJBc3NlbWJseVNpbWQiLCJleHBpcnkiOjE2MDg2NzI5OTR9',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const originTrialId = branchOriginTrialIds.get(branch || '');
|
||||||
|
|
||||||
interface Output {
|
interface Output {
|
||||||
[outputPath: string]: string;
|
[outputPath: string]: string;
|
||||||
@@ -57,6 +74,27 @@ const toOutput: Output = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
_headers: dedent`
|
||||||
|
/*
|
||||||
|
Cache-Control: no-cache
|
||||||
|
|
||||||
|
/c/*
|
||||||
|
Cache-Control: max-age=31536000
|
||||||
|
|
||||||
|
# COOP+COEP for WebAssembly threads.
|
||||||
|
/*
|
||||||
|
Cross-Origin-Embedder-Policy: require-corp
|
||||||
|
Cross-Origin-Opener-Policy: same-origin
|
||||||
|
|
||||||
|
# Origin trial for WebAssembly SIMD.
|
||||||
|
${
|
||||||
|
originTrialId
|
||||||
|
? ` Origin-Trial: ${originTrialId}`
|
||||||
|
: `# Cannot find origin trial ID. process.env.BRANCH is: ${JSON.stringify(
|
||||||
|
branch,
|
||||||
|
)}`
|
||||||
|
}
|
||||||
|
`,
|
||||||
};
|
};
|
||||||
|
|
||||||
writeFiles(toOutput);
|
writeFiles(toOutput);
|
||||||
|
|||||||
Reference in New Issue
Block a user