Last active
November 8, 2024 22:28
-
-
Save ditman/cb6d1d78be6dc55bb5a0290d08649c8b to your computer and use it in GitHub Desktop.
Sample Firebase hosting configuration for Flutter web.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hosting": { | |
"public": "build/web", | |
"ignore": [ | |
"firebase.json", | |
"**/.*", | |
"**/node_modules/**" | |
], | |
"headers": [ | |
{ | |
"source": "**/*", | |
"headers": [ | |
{ | |
"key": "Cross-Origin-Embedder-Policy", | |
"value": "credentialless" | |
}, | |
{ | |
"key": "Cross-Origin-Opener-Policy", | |
"value": "same-origin" | |
}, | |
{ | |
"key": "Cache-Control", | |
"value": "no-cache, no-store, must-revalidate" | |
} | |
] | |
}, | |
{ | |
"source": | |
"**/*.@(jpg|jpeg|gif|png|svg|webp|css|eot|otf|ttf|ttc|woff|woff2|font.css)", | |
"headers": [ | |
{ | |
"key": "Cache-Control", | |
"value": "max-age=3600,s-maxage=604800" | |
} | |
] | |
}, | |
{ | |
"source": | |
"**/*.@(mjs|js|wasm|json)", | |
"headers": [ | |
{ | |
"key": "Cache-Control", | |
"value": "max-age=0,s-maxage=604800" | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cache
In all cases, exceptions for specific files can be made, like the (non-existent in Flutter web
font.css
file).Wasm
This gist also adds COEP/COOP (
Cross-Origin-Embedder-Policy
andCross-Origin-Opener-Policy
so shared array buffers become available, and Wasm can work in multi-threaded mode)