Fix CORS: API-Endpunkt statt Raw-URL

This commit is contained in:
2026-04-17 12:39:24 +00:00
parent 4a7b13a94d
commit df4b319b9e

View File

@@ -1667,7 +1667,8 @@
// CONSTANTS & CHAPTER CONFIG
// ============================================================
const APP_VERSION = '1.1.0';
const GITEA_RAW = 'http://72.60.134.73:3000/cheubaum/BNI-Sonne/raw/branch/main';
const GITEA_RAW = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Sonne/raw';
function giteaUrl(path) { return `${GITEA_RAW}/${path}?ref=main`; }
const CHAPTER_CONFIG_KEY = 'bni-active-chapter';
function loadChapterConfig() {
@@ -4029,7 +4030,7 @@ async function activateChapter() {
status.textContent = 'Überprüfe Lizenzcode…';
status.style.color = 'rgba(255,255,255,0.6)';
try {
const res = await fetch(`${GITEA_RAW}/chapters/${code}/config.json`, { cache: 'no-store' });
const res = await fetch(giteaUrl(`chapters/${code}/config.json`), { cache: 'no-store' });
if (!res.ok) {
status.textContent = 'Ungültiger oder abgelaufener Lizenzcode.';
status.style.color = '#f87171';
@@ -4070,7 +4071,7 @@ function applyChapterUI(config) {
if (ctrlName) ctrlName.textContent = `${name} – Steuerung`;
if (config.logoUrl && activeChapter) {
const src = config.logoUrl.startsWith('http') ? config.logoUrl
: `${GITEA_RAW}/chapters/${activeChapter.code}/${config.logoUrl}`;
: giteaUrl(`chapters/${activeChapter.code}/${config.logoUrl}`);
['display-logo','display-logo-empty','ctrl-logo'].forEach(id => {
const img = document.getElementById(id);
if (img) img.src = src;
@@ -4086,7 +4087,7 @@ function applyChapterUI(config) {
async function checkLicenseAndUpdates() {
if (!activeChapter) return;
try {
const res = await fetch(`${GITEA_RAW}/chapters/${activeChapter.code}/config.json`, { cache: 'no-store' });
const res = await fetch(giteaUrl(`chapters/${activeChapter.code}/config.json`), { cache: 'no-store' });
if (!res.ok) {
clearChapterData();
state = defaultState();
@@ -4109,7 +4110,7 @@ async function checkLicenseAndUpdates() {
async function checkForUpdates() {
try {
const res = await fetch(`${GITEA_RAW}/version.json`, { cache: 'no-store' });
const res = await fetch(giteaUrl('version.json'), { cache: 'no-store' });
if (!res.ok) return;
const data = await res.json();
if (data.version && data.version > APP_VERSION) showUpdateBanner(data.version, data.notes);
@@ -4130,7 +4131,7 @@ function showUpdateBanner(version, notes) {
async function downloadUpdate(version) {
try {
const licRes = await fetch(`${GITEA_RAW}/chapters/${activeChapter.code}/config.json`, { cache: 'no-store' });
const licRes = await fetch(giteaUrl(`chapters/${activeChapter.code}/config.json`), { cache: 'no-store' });
if (!licRes.ok) {
clearChapterData();
state = defaultState();
@@ -4140,7 +4141,7 @@ async function downloadUpdate(version) {
}
} catch(e) { alert('Keine Serververbindung möglich.'); return; }
try {
const res = await fetch(`${GITEA_RAW}/index.html`, { cache: 'no-store' });
const res = await fetch(giteaUrl('index.html'), { cache: 'no-store' });
const html = await res.text();
const blob = new Blob([html], { type: 'text/html' });
const a = document.createElement('a');
@@ -4154,7 +4155,7 @@ async function downloadUpdate(version) {
async function fetchChapterMembersFromGitea() {
if (!activeChapter) return;
try {
const res = await fetch(`${GITEA_RAW}/chapters/${activeChapter.code}/members.json`, { cache: 'no-store' });
const res = await fetch(giteaUrl(`chapters/${activeChapter.code}/members.json`), { cache: 'no-store' });
if (!res.ok) return;
const data = await res.json();
if (!data.members || !data.members.length) return;