fix(production) : prevent hydration and service failures
This commit is contained in:
+6
-1
@@ -770,7 +770,12 @@ async function executeCatalogSyncJob(initial: CatalogSyncJob, actor: AuditActor)
|
||||
}
|
||||
|
||||
export async function getCurrentCatalogVersion(): Promise<string | null> {
|
||||
return (await getCurrentCatalogState())?.version ?? null;
|
||||
try {
|
||||
return (await getCurrentCatalogState())?.version ?? null;
|
||||
} catch (error) {
|
||||
console.error("Unable to read the current catalog version", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function getCurrentCatalogState() {
|
||||
|
||||
@@ -121,10 +121,15 @@ export async function getActiveCatalog() {
|
||||
if (!characters.length) return null;
|
||||
const groupedAliases = aliasesByItem(aliases);
|
||||
const materialByKey = new Map(materials.map((item) => [item.key, item]));
|
||||
const storage = await getMediaStorage();
|
||||
const { version } = catalogVersionSchema.parse(
|
||||
await storage.file("catalog/current.json").json(),
|
||||
);
|
||||
let version = "unknown";
|
||||
try {
|
||||
const storage = await getMediaStorage();
|
||||
version = catalogVersionSchema.parse(
|
||||
await storage.file("catalog/current.json").json(),
|
||||
).version;
|
||||
} catch (error) {
|
||||
console.error("Unable to read the active catalog version", error);
|
||||
}
|
||||
return {
|
||||
version,
|
||||
characters: characters.map((item) => ({ ...catalogCharacterWithUrls(item, materialByKey), aliases: groupedAliases.character.get(item.key) ?? [] })),
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
export function securityHeaders(production: boolean) {
|
||||
const ads = "https://*.googlesyndication.com https://*.doubleclick.net https://*.googleadservices.com https://*.googletagservices.com https://www.google.com";
|
||||
const cloudflareAnalytics = "https://static.cloudflareinsights.com";
|
||||
const adConnections = "https://*.adtrafficquality.google";
|
||||
const policy = [
|
||||
"default-src 'self'",
|
||||
`script-src 'self' 'unsafe-inline' ${production ? "" : "'unsafe-eval'"} https://challenges.cloudflare.com ${ads}`,
|
||||
`script-src 'self' 'unsafe-inline' ${production ? "" : "'unsafe-eval'"} https://challenges.cloudflare.com ${cloudflareAnalytics} ${ads}`,
|
||||
"style-src 'self' 'unsafe-inline'",
|
||||
`img-src 'self' data: blob: https://buzz-cdn.astrxl.dev ${ads}`,
|
||||
"font-src 'self' data:",
|
||||
`connect-src 'self' https://buzz-cdn.astrxl.dev https://challenges.cloudflare.com ${ads}${production ? "" : " ws: wss:"}`,
|
||||
`connect-src 'self' https://buzz-cdn.astrxl.dev https://challenges.cloudflare.com ${adConnections} ${ads}${production ? "" : " ws: wss:"}`,
|
||||
`frame-src https://challenges.cloudflare.com https://www.youtube-nocookie.com ${ads}`,
|
||||
"media-src 'self' blob:",
|
||||
"worker-src 'self' blob:",
|
||||
|
||||
Reference in New Issue
Block a user