mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
@@ -61,7 +61,7 @@ const ArticleDetailPage: React.FC = () => {
|
||||
queryKey: ['facr-cached-match', (matchLinkQuery.data as any)?.external_match_id],
|
||||
enabled: Boolean((matchLinkQuery.data as any)?.external_match_id),
|
||||
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_club_info.json`;
|
||||
const res = await fetch(url, { cache: 'no-cache' });
|
||||
if (!res.ok) return null as any;
|
||||
@@ -105,8 +105,7 @@ const ArticleDetailPage: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const apiUrl = process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
const origin = new URL(apiUrl).origin;
|
||||
const origin = new URL(API_URL, window.location.origin).origin;
|
||||
|
||||
// Try to find album in both sources
|
||||
const [profileRes, albumsRes] = await Promise.allSettled([
|
||||
|
||||
@@ -8,6 +8,7 @@ import { assetUrl, sanitizeClubName } from '../utils/url';
|
||||
import MatchModal from '../components/home/MatchModal';
|
||||
import { useCountdown, useMultipleCountdowns } from '../hooks/useCountdown';
|
||||
import '../styles/theme.css';
|
||||
import { API_URL } from '../services/api';
|
||||
|
||||
type MatchItem = {
|
||||
id: number | string;
|
||||
@@ -225,8 +226,7 @@ const MatchesPage: React.FC = () => {
|
||||
try {
|
||||
if (/^https?:\/\//i.test(path)) return path;
|
||||
if (path.startsWith('/cache') || path.startsWith('/uploads') || path.startsWith('/api/')) {
|
||||
const base = process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
const b = new URL(base);
|
||||
const b = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : undefined);
|
||||
const abs = new URL(path, `${b.protocol}//${b.host}`);
|
||||
return abs.toString();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import ClubModal from '../components/home/ClubModal';
|
||||
import { usePublicSettings } from '../hooks/usePublicSettings';
|
||||
import { sortCategoriesWithOrder } from '../utils/categorySort';
|
||||
import { TeamLogo } from '../components/common/TeamLogo';
|
||||
import { API_URL } from '../services/api';
|
||||
|
||||
type TableRow = {
|
||||
rank: string;
|
||||
@@ -34,10 +35,9 @@ const resolveBackendUrl = (path: string) => {
|
||||
try {
|
||||
if (/^https?:\/\//i.test(path)) return path;
|
||||
if (path.startsWith('/cache') || path.startsWith('/uploads')) {
|
||||
const base = process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
const u = new URL(base);
|
||||
u.pathname = path;
|
||||
return u.toString();
|
||||
const u = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : undefined);
|
||||
const abs = new URL(path, `${u.protocol}//${u.host}`);
|
||||
return abs.toString();
|
||||
}
|
||||
return path;
|
||||
} catch {
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user