Implemented offline-first fast-paths and hardened API/Layout resilience. Added reactive offline banner, root error page, and ghost site fallbacks to handle server downtime and connection loss without crashing.
This commit is contained in:
@@ -6,6 +6,9 @@ import { lookup_site_domain } from '$lib/ae_core/ae_core__site';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import type { ae_SiteDomain } from '$lib/types/ae_types';
|
||||
|
||||
export const ssr = false;
|
||||
export const prerender = false;
|
||||
|
||||
import {
|
||||
PUBLIC_AE_API_PROTOCOL,
|
||||
PUBLIC_AE_API_SERVER,
|
||||
@@ -104,25 +107,41 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
|
||||
const fqdn = url.host;
|
||||
|
||||
const result = await lookup_site_domain({
|
||||
api_cfg: ae_api_init,
|
||||
fqdn,
|
||||
view: 'base',
|
||||
log_lvl
|
||||
}).catch((err) => {
|
||||
console.log('Site lookup failed in root layout.', err);
|
||||
error(500, {
|
||||
message: 'Site lookup aborted or failed! Check network and API.'
|
||||
});
|
||||
});
|
||||
|
||||
if (result === null) {
|
||||
error(403, {
|
||||
message: 'The site lookup failed! Check that the domain name is configured and enabled.'
|
||||
let result: ae_SiteDomain | null = null;
|
||||
try {
|
||||
result = await lookup_site_domain({
|
||||
api_cfg: ae_api_init,
|
||||
fqdn,
|
||||
view: 'base',
|
||||
log_lvl
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Site lookup critical failure in root layout.', err);
|
||||
}
|
||||
|
||||
const json_data = result;
|
||||
if (result === null) {
|
||||
console.warn('Site lookup returned null. Attempting emergency ghost fallback.');
|
||||
// This is a last resort if the internal library fallback also failed
|
||||
result = {
|
||||
id: 'ghost',
|
||||
id_random: 'ghost',
|
||||
account_id_random: 'ghost',
|
||||
account_code: 'ghost',
|
||||
account_name: 'Ghost Account',
|
||||
site_id_random: 'ghost',
|
||||
site_domain_id_random: 'ghost',
|
||||
enable: '1',
|
||||
header_image_path: '',
|
||||
style_href: '',
|
||||
google_tracking_id: '',
|
||||
access_code_kv_json: {},
|
||||
cfg_json: {},
|
||||
access_key: '',
|
||||
site_domain_access_key: ''
|
||||
} as any;
|
||||
}
|
||||
|
||||
const json_data = result as any;
|
||||
account_id = json_data.account_id_random;
|
||||
data_struct.account_id = json_data.account_id_random;
|
||||
ae_acct.account_id = json_data.account_id_random;
|
||||
|
||||
Reference in New Issue
Block a user