Fix CORS-Preflight: Token als URL-Parameter

This commit is contained in:
2026-04-19 11:24:55 +00:00
parent 4b4f81a441
commit 7e524593c0

View File

@@ -1715,6 +1715,7 @@ const APP_VERSION = '1.1.0';
const GITEA_RAW = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde/raw'; const GITEA_RAW = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde/raw';
const GITEA_API = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde'; const GITEA_API = 'http://72.60.134.73:3000/api/v1/repos/cheubaum/BNI-Vorstellungsrunde';
function giteaUrl(path) { return `${GITEA_RAW}/${path}?ref=main`; } function giteaUrl(path) { return `${GITEA_RAW}/${path}?ref=main`; }
function giteaAuthUrl(path, token) { return `${GITEA_API}/contents/${path}?token=${encodeURIComponent(token)}`; }
const CHAPTER_CONFIG_KEY = 'bni-active-chapter'; const CHAPTER_CONFIG_KEY = 'bni-active-chapter';
function loadChapterConfig() { function loadChapterConfig() {
@@ -4409,15 +4410,15 @@ async function uploadMembersToGitea() {
try { try {
// Get current SHA // Get current SHA
let sha = null; let sha = null;
const shaRes = await fetch(`${GITEA_API}/contents/${path}`, { headers: { 'Authorization': `token ${token}` } }); const shaRes = await fetch(giteaAuthUrl(path, token));
if (shaRes.ok) sha = (await shaRes.json()).sha; if (shaRes.ok) sha = (await shaRes.json()).sha;
const body = { message: `Mitglieder aktualisiert ${new Date().toLocaleDateString('de')}`, content }; const body = { message: `Mitglieder aktualisiert ${new Date().toLocaleDateString('de')}`, content };
if (sha) body.sha = sha; if (sha) body.sha = sha;
const res = await fetch(`${GITEA_API}/contents/${path}`, { const res = await fetch(giteaAuthUrl(path, token), {
method: sha ? 'PUT' : 'POST', method: sha ? 'PUT' : 'POST',
headers: { 'Authorization': `token ${token}`, 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body) body: JSON.stringify(body)
}); });
if (res.ok) { if (res.ok) {