hot fix #5 dev day #70

This commit is contained in:
Tomas Dvorak
2025-10-24 23:21:57 +02:00
parent b8839fc1ff
commit 81389c108f
13 changed files with 45 additions and 37 deletions
@@ -48,7 +48,7 @@ const SponsorsAdminPage: React.FC = () => {
const normalizeImageUrl = (url?: string) => {
if (!url || url === '') return '/logo192.png';
if (/^https?:\/\//i.test(url)) return url;
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
const origin = new URL(API_URL, window.location.origin).origin;
if (url.startsWith('/uploads/')) return `${origin}${url}`;
return `${origin}${url.startsWith('/') ? '' : '/'}${url}`;
};
@@ -129,8 +129,7 @@ const SponsorsAdminPage: React.FC = () => {
if (!file) return;
try {
const res = await uploadFile(file);
const apiUrl = process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
const apiOrigin = new URL(apiUrl).origin;
const apiOrigin = new URL(API_URL, window.location.origin).origin;
// If backend returned an absolute URL pointing to the dev host (same origin as app), rewrite to API origin
let url = res.url || '';
try {
@@ -23,7 +23,7 @@ const StandingsAdminPage: React.FC = () => {
const { data, isLoading, error } = useQuery<any>({
queryKey: ['facr-tables-cache'],
queryFn: async () => {
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
const origin = new URL(API_URL, window.location.origin).origin;
const url = `${origin}/cache/prefetch/facr_tables.json`;
const res = await fetch(url, { headers: { 'Cache-Control': 'no-cache' } });
if (!res.ok) throw new Error(`Failed to load cache: ${res.status}`);