fix(pwa): enable crossorigin=use-credentials for manifest, add id and header install trigger
This commit is contained in:
@@ -82,8 +82,8 @@ def get_s3_client():
|
||||
)
|
||||
|
||||
|
||||
def publish_to_s3(html_content: str, key: str = "moritz.html") -> str:
|
||||
"""Uploads the rendered HTML to MinIO hosting bucket."""
|
||||
def publish_to_s3(html_content: str, key: str = "family/moritz.html", data_dir: Optional[Path] = None) -> str:
|
||||
"""Uploads the rendered HTML and webmanifest to MinIO hosting bucket."""
|
||||
s3 = get_s3_client()
|
||||
s3.put_object(
|
||||
Bucket=DEFAULT_BUCKET,
|
||||
@@ -92,6 +92,22 @@ def publish_to_s3(html_content: str, key: str = "moritz.html") -> str:
|
||||
ContentType="text/html; charset=utf-8",
|
||||
CacheControl="no-cache, no-store, must-revalidate",
|
||||
)
|
||||
# Also upload moritz.webmanifest if present
|
||||
assets_dir = SCRIPT_DIR.parent / "assets"
|
||||
manifest_file = assets_dir / "moritz.webmanifest"
|
||||
if not manifest_file.is_file() and data_dir:
|
||||
manifest_file = data_dir.parent / "public" / "family" / "moritz.webmanifest"
|
||||
if manifest_file.is_file():
|
||||
try:
|
||||
s3.put_object(
|
||||
Bucket=DEFAULT_BUCKET,
|
||||
Key="family/moritz.webmanifest",
|
||||
Body=manifest_file.read_bytes(),
|
||||
ContentType="application/manifest+json; charset=utf-8",
|
||||
CacheControl="no-cache, no-store, must-revalidate",
|
||||
)
|
||||
except Exception as ex:
|
||||
print(f"Warning: could not upload family/moritz.webmanifest: {ex}", file=sys.stderr)
|
||||
return f"{DEFAULT_BASE_URL}/{key}"
|
||||
|
||||
|
||||
@@ -546,7 +562,7 @@ def generate_dashboard_html(engine: DatastoreEngine) -> str:
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||
<meta name="apple-mobile-web-app-title" content="Moritz Health">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<link rel="manifest" href="{manifest_data_uri}">
|
||||
<link rel="manifest" href="/family/moritz.webmanifest" crossorigin="use-credentials">
|
||||
<link rel="apple-touch-icon" href="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><rect width='512' height='512' rx='128' fill='%2310b981'/><path d='M128 256h64l32-96 64 192 32-96h64' fill='none' stroke='white' stroke-width='40' stroke-linecap='round' stroke-linejoin='round'/></svg>">
|
||||
|
||||
<!-- Tailwind CSS & Lucide Icons -->
|
||||
@@ -1231,10 +1247,10 @@ def main():
|
||||
# 2. Upload strictly to protected S3 hosting under /family/
|
||||
if not args.skip_upload:
|
||||
try:
|
||||
url = publish_to_s3(html, key="family/moritz.html")
|
||||
url = publish_to_s3(html, key="family/moritz.html", data_dir=data_dir)
|
||||
print(f"🚀 Published successfully to: {url}")
|
||||
# Also publish to /family/nutrition.html for backwards compatibility
|
||||
publish_to_s3(html, key="family/nutrition.html")
|
||||
publish_to_s3(html, key="family/nutrition.html", data_dir=data_dir)
|
||||
except Exception as e:
|
||||
print(f"⚠️ S3 upload failed (local testing?): {e}", file=sys.stderr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user