fix favicon delivery and cache invalidation

This commit is contained in:
MOH
2026-03-07 19:19:58 +01:00
parent cd6ec7fa78
commit 3d1976a7a5
8 changed files with 193 additions and 7 deletions
+20
View File
@@ -0,0 +1,20 @@
import { NextResponse } from "next/server";
import { buildFallbackIconResponse, getDynamicSiteIconUrls } from "@/lib/site-icons";
export const dynamic = "force-dynamic";
export const revalidate = 0;
export async function GET() {
const iconUrls = await getDynamicSiteIconUrls();
if (iconUrls.faviconAssetUrl) {
const response = NextResponse.redirect(iconUrls.faviconAssetUrl, 307);
response.headers.set("Cache-Control", "no-store, max-age=0");
return response;
}
return buildFallbackIconResponse(iconUrls.siteName, 180);
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

+20
View File
@@ -0,0 +1,20 @@
import { NextResponse } from "next/server";
import { buildFallbackIconResponse, getDynamicSiteIconUrls } from "@/lib/site-icons";
export const dynamic = "force-dynamic";
export const revalidate = 0;
export async function GET() {
const iconUrls = await getDynamicSiteIconUrls();
if (iconUrls.faviconAssetUrl) {
const response = NextResponse.redirect(iconUrls.faviconAssetUrl, 307);
response.headers.set("Cache-Control", "no-store, max-age=0");
return response;
}
return buildFallbackIconResponse(iconUrls.siteName, 32);
}
+8
View File
@@ -1,11 +1,17 @@
import type { Metadata } from "next";
import { unstable_noStore as noStore } from "next/cache";
import { getLocale } from "next-intl/server";
import { ThemeProvider } from "@/components/theme-provider";
import { buildAppMetadata } from "@/lib/metadata";
import { getDirection } from "@/lib/locale";
import "./globals.css";
export const dynamic = "force-dynamic";
export const revalidate = 0;
export async function generateMetadata(): Promise<Metadata> {
noStore();
return buildAppMetadata();
}
@@ -14,6 +20,8 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
noStore();
const locale = await getLocale().catch(() => "de");
return (
+30
View File
@@ -0,0 +1,30 @@
import type { MetadataRoute } from "next";
import { getDynamicSiteIconUrls } from "@/lib/site-icons";
export const dynamic = "force-dynamic";
export const revalidate = 0;
export default async function manifest(): Promise<MetadataRoute.Manifest> {
const iconUrls = await getDynamicSiteIconUrls();
return {
name: iconUrls.siteName,
short_name: iconUrls.siteName,
icons: [
{
src: iconUrls.appleIconHref,
sizes: "180x180",
type: "image/png",
},
{
src: iconUrls.faviconHref,
sizes: "32x32",
type: "image/x-icon",
},
],
display: "standalone",
background_color: "#ffffff",
theme_color: "#111827",
};
}
+1
View File
@@ -13,6 +13,7 @@ type MediaFileRouteProps = {
export const dynamic = "force-dynamic";
const CONTENT_TYPES: Record<string, string> = {
".ico": "image/x-icon",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".png": "image/png",