Compare commits

..
2 Commits
Author SHA1 Message Date
radoslaw.smolinski f9d3d9ae97 1.6.4 2026-10-09 19:10:25 +02:00
radoslaw.smolinski 962b9cb640 Fixed buildManifest.ts 2026-10-09 19:10:20 +02:00
5 changed files with 79 additions and 23 deletions
+9
View File
@@ -24,6 +24,15 @@ type Manifest = {
* import { getCachedPayload } from '@/lib/content'
* import { i18nConfig } from '@/i18n.config'
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
*
* NOTE on Docker/CI builds: the whole DB access is wrapped in try/catch, so a
* `next build` with no reachable database (the usual Coolify/Docker case) gets
* a minimal valid manifest instead of a crash — same contract as
* generateStaticParams and the sitemap handler. Projects should still mark the
* route dynamic so Next doesn't prerender it at build time:
*
* // app/manifest.ts
* export const dynamic = 'force-dynamic'
*/
export declare function createManifestHandler(opts: {
config: I18nConfig;
+32 -11
View File
@@ -9,22 +9,43 @@ import { getDefaultLocale } from '../i18n/index.js';
* import { getCachedPayload } from '@/lib/content'
* import { i18nConfig } from '@/i18n.config'
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
*
* NOTE on Docker/CI builds: the whole DB access is wrapped in try/catch, so a
* `next build` with no reachable database (the usual Coolify/Docker case) gets
* a minimal valid manifest instead of a crash — same contract as
* generateStaticParams and the sitemap handler. Projects should still mark the
* route dynamic so Next doesn't prerender it at build time:
*
* // app/manifest.ts
* export const dynamic = 'force-dynamic'
*/ export function createManifestHandler(opts) {
return async ()=>{
const defaultLocale = getDefaultLocale(opts.config);
const payload = await opts.getCachedPayload();
const settings = await payload.findGlobal({
slug: opts.settingsSlug ?? 'site-settings',
depth: 1,
locale: defaultLocale
}).catch(()=>null);
const start_url = `/${defaultLocale}`;
// Minimal, always-valid manifest. Used both when SiteSettings is empty and
// when the database is unreachable during a build.
const fallback = {
display: 'standalone',
icons: [],
start_url
};
let settings;
try {
// getCachedPayload() ITSELF throws when the DB can't be reached (e.g.
// `getaddrinfo ENOTFOUND` during `docker build`), BEFORE findGlobal runs
// — so the whole thing, not just the query, must sit inside try/catch.
const payload = await opts.getCachedPayload();
settings = await payload.findGlobal({
slug: opts.settingsSlug ?? 'site-settings',
depth: 1,
locale: defaultLocale
}).catch(()=>null);
} catch (err) {
console.warn('[ipal] createManifestHandler: database not reachable during build (Docker/CI) — returning minimal manifest; it fills in at runtime:', err);
return fallback;
}
if (!settings) {
return {
display: 'standalone',
icons: [],
start_url
};
return fallback;
}
const iconSource = settings.favicon ?? settings.logo;
const icons = [];
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@intecion/ipal-kit",
"version": "1.6.3",
"version": "1.6.4",
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
"license": "MIT",
"repository": {
+36 -10
View File
@@ -39,6 +39,15 @@ type SettingsShape = {
* import { getCachedPayload } from '@/lib/content'
* import { i18nConfig } from '@/i18n.config'
* export default createManifestHandler({ getCachedPayload, config: i18nConfig })
*
* NOTE on Docker/CI builds: the whole DB access is wrapped in try/catch, so a
* `next build` with no reachable database (the usual Coolify/Docker case) gets
* a minimal valid manifest instead of a crash — same contract as
* generateStaticParams and the sitemap handler. Projects should still mark the
* route dynamic so Next doesn't prerender it at build time:
*
* // app/manifest.ts
* export const dynamic = 'force-dynamic'
*/
export function createManifestHandler(opts: {
config: I18nConfig
@@ -47,18 +56,35 @@ export function createManifestHandler(opts: {
}): () => Promise<Manifest> {
return async () => {
const defaultLocale = getDefaultLocale(opts.config)
const payload = await opts.getCachedPayload()
const settings = (await payload
.findGlobal({
slug: (opts.settingsSlug ?? 'site-settings') as never,
depth: 1,
locale: defaultLocale as never,
})
.catch(() => null)) as null | SettingsShape
const start_url = `/${defaultLocale}`
// Minimal, always-valid manifest. Used both when SiteSettings is empty and
// when the database is unreachable during a build.
const fallback: Manifest = { display: 'standalone', icons: [], start_url }
let settings: null | SettingsShape
try {
// getCachedPayload() ITSELF throws when the DB can't be reached (e.g.
// `getaddrinfo ENOTFOUND` during `docker build`), BEFORE findGlobal runs
// — so the whole thing, not just the query, must sit inside try/catch.
const payload = await opts.getCachedPayload()
settings = (await payload
.findGlobal({
slug: (opts.settingsSlug ?? 'site-settings') as never,
depth: 1,
locale: defaultLocale as never,
})
.catch(() => null)) as null | SettingsShape
} catch (err) {
console.warn(
'[ipal] createManifestHandler: database not reachable during build (Docker/CI) — returning minimal manifest; it fills in at runtime:',
err,
)
return fallback
}
if (!settings) {
return { display: 'standalone', icons: [], start_url }
return fallback
}
const iconSource = settings.favicon ?? settings.logo