fix(dashboard): stop discarding the saved Postiz base URL every load

The retired maintainer default is now blanked once (marker-guarded) instead of on every read, so a self-hoster whose own Postiz instance lives on that host no longer has to retype the URL each session.
This commit is contained in:
pedro-bento 2026-10-05 18:23:21 +01:00
parent a3c877e032
commit 7c260b3fa1

View file

@ -159,14 +159,23 @@ const postizHeaders = (key, url) => {
// Older builds defaulted to a maintainer-hosted Postiz instance and persisted
// it to localStorage on mount, so an upgrade could silently keep sending a
// user's API key to someone else's server. Recognize that retired default and
// treat it as unset. The host is assembled from parts so no live reference to
// it remains in the source.
// user's API key to a server they never chose. Retire that one legacy value
// ONCE (guarded by a marker) instead of on every read: blanking it on each load
// also threw away a URL the user deliberately saved — a self-hoster's own
// instance can legitimately live on that host — and forced them to retype it
// every session. The host is assembled from parts so no live reference to it
// remains in the source.
const RETIRED_POSTIZ_HOST = ['postiz', 'pbento', 'pt'].join('.');
const POSTIZ_URL_RETIRED_KEY = 'postiz_url_retired_v1';
const normalizeStoredPostizUrl = (url) => {
const base = String(url || '').trim().replace(/\/$/, '');
if (!base) return '';
return base === `https://${RETIRED_POSTIZ_HOST}` ? '' : base;
let retired = false;
try {
retired = localStorage.getItem(POSTIZ_URL_RETIRED_KEY) === '1';
localStorage.setItem(POSTIZ_URL_RETIRED_KEY, '1');
} catch (_) { /* storage unavailable: nothing to migrate */ }
return !retired && base === `https://${RETIRED_POSTIZ_HOST}` ? '' : base;
};
const SESSION_KEY = 'clipwright_session';