fix: devUser-Parameter an alle API-Calls weiterleiten
Im Dev-Modus wurde der devUser Query-Parameter aus der Browser-URL nicht an die Backend-API-Calls weitergegeben. Dadurch liefen alle Requests immer als devUser=1 (Ronny), unabhängig vom gewählten User. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
const BASE = '/api';
|
||||
|
||||
function withDevUser(path: string): string {
|
||||
const devUser = new URLSearchParams(window.location.search).get('devUser');
|
||||
if (!devUser) return path;
|
||||
const sep = path.includes('?') ? '&' : '?';
|
||||
return `${path}${sep}devUser=${devUser}`;
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options?: RequestInit): Promise<T> {
|
||||
const res = await fetch(`${BASE}${path}`, {
|
||||
const res = await fetch(`${BASE}${withDevUser(path)}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user