Fix CORS: API-Endpunkt statt Raw-URL
This commit is contained in:
17
index.html
17
index.html
@@ -1667,7 +1667,8 @@
|
|||||||
// CONSTANTS & CHAPTER CONFIG
|
// CONSTANTS & CHAPTER CONFIG
|
||||||
// ============================================================
|
// ============================================================
|
||||||
const APP_VERSION = '1.1.0';
|
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';
|
const CHAPTER_CONFIG_KEY = 'bni-active-chapter';
|
||||||
|
|
||||||
function loadChapterConfig() {
|
function loadChapterConfig() {
|
||||||
@@ -4029,7 +4030,7 @@ async function activateChapter() {
|
|||||||
status.textContent = 'Überprüfe Lizenzcode…';
|
status.textContent = 'Überprüfe Lizenzcode…';
|
||||||
status.style.color = 'rgba(255,255,255,0.6)';
|
status.style.color = 'rgba(255,255,255,0.6)';
|
||||||
try {
|
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) {
|
if (!res.ok) {
|
||||||
status.textContent = 'Ungültiger oder abgelaufener Lizenzcode.';
|
status.textContent = 'Ungültiger oder abgelaufener Lizenzcode.';
|
||||||
status.style.color = '#f87171';
|
status.style.color = '#f87171';
|
||||||
@@ -4070,7 +4071,7 @@ function applyChapterUI(config) {
|
|||||||
if (ctrlName) ctrlName.textContent = `${name} – Steuerung`;
|
if (ctrlName) ctrlName.textContent = `${name} – Steuerung`;
|
||||||
if (config.logoUrl && activeChapter) {
|
if (config.logoUrl && activeChapter) {
|
||||||
const src = config.logoUrl.startsWith('http') ? config.logoUrl
|
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 => {
|
['display-logo','display-logo-empty','ctrl-logo'].forEach(id => {
|
||||||
const img = document.getElementById(id);
|
const img = document.getElementById(id);
|
||||||
if (img) img.src = src;
|
if (img) img.src = src;
|
||||||
@@ -4086,7 +4087,7 @@ function applyChapterUI(config) {
|
|||||||
async function checkLicenseAndUpdates() {
|
async function checkLicenseAndUpdates() {
|
||||||
if (!activeChapter) return;
|
if (!activeChapter) return;
|
||||||
try {
|
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) {
|
if (!res.ok) {
|
||||||
clearChapterData();
|
clearChapterData();
|
||||||
state = defaultState();
|
state = defaultState();
|
||||||
@@ -4109,7 +4110,7 @@ async function checkLicenseAndUpdates() {
|
|||||||
|
|
||||||
async function checkForUpdates() {
|
async function checkForUpdates() {
|
||||||
try {
|
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;
|
if (!res.ok) return;
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data.version && data.version > APP_VERSION) showUpdateBanner(data.version, data.notes);
|
if (data.version && data.version > APP_VERSION) showUpdateBanner(data.version, data.notes);
|
||||||
@@ -4130,7 +4131,7 @@ function showUpdateBanner(version, notes) {
|
|||||||
|
|
||||||
async function downloadUpdate(version) {
|
async function downloadUpdate(version) {
|
||||||
try {
|
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) {
|
if (!licRes.ok) {
|
||||||
clearChapterData();
|
clearChapterData();
|
||||||
state = defaultState();
|
state = defaultState();
|
||||||
@@ -4140,7 +4141,7 @@ async function downloadUpdate(version) {
|
|||||||
}
|
}
|
||||||
} catch(e) { alert('Keine Serververbindung möglich.'); return; }
|
} catch(e) { alert('Keine Serververbindung möglich.'); return; }
|
||||||
try {
|
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 html = await res.text();
|
||||||
const blob = new Blob([html], { type: 'text/html' });
|
const blob = new Blob([html], { type: 'text/html' });
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
@@ -4154,7 +4155,7 @@ async function downloadUpdate(version) {
|
|||||||
async function fetchChapterMembersFromGitea() {
|
async function fetchChapterMembersFromGitea() {
|
||||||
if (!activeChapter) return;
|
if (!activeChapter) return;
|
||||||
try {
|
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;
|
if (!res.ok) return;
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!data.members || !data.members.length) return;
|
if (!data.members || !data.members.length) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user