mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { assetUrl } from '../../utils/url';
|
||||
import { API_URL } from '../../services/api';
|
||||
|
||||
interface Sponsor {
|
||||
id: number | string;
|
||||
@@ -18,9 +19,8 @@ const resolveBackendUrl = (path: string) => {
|
||||
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 abs = new URL(path, `${b.protocol}//${b.host}`);
|
||||
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
const abs = new URL(path, origin);
|
||||
return abs.toString();
|
||||
}
|
||||
return path;
|
||||
@@ -42,7 +42,7 @@ const SponsorsSection: React.FC<SponsorsSectionProps> = ({
|
||||
const fetchSponsors = async () => {
|
||||
try {
|
||||
// Try API first
|
||||
const apiRes = await fetch(`${process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1'}/public/sponsors`);
|
||||
const apiRes = await fetch(`${API_URL}/public/sponsors`);
|
||||
if (apiRes.ok) {
|
||||
const data = await apiRes.json();
|
||||
if (!cancelled && Array.isArray(data)) {
|
||||
|
||||
Reference in New Issue
Block a user