mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
@@ -1,6 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
import { API_URL as API_BASE_URL } from './api';
|
||||
|
||||
export interface ClothingItem {
|
||||
id: number;
|
||||
|
||||
@@ -4,10 +4,8 @@ import { API_URL } from '../api';
|
||||
function resolveBackend(path: string): string {
|
||||
try {
|
||||
if (/^https?:\/\//i.test(path)) return path;
|
||||
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.startsWith('/') ? path : `/${path}`;
|
||||
return u.toString();
|
||||
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
return new URL(path.startsWith('/') ? path : `/${path}`, origin).toString();
|
||||
} catch {
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const cache = new Map<string, CacheItem<any>>();
|
||||
|
||||
// Create axios instance with base URL from environment variables
|
||||
const apiClient: AxiosInstance = axios.create({
|
||||
baseURL: process.env.REACT_APP_FACR_API_BASE_URL || 'http://localhost:8080/api/v1/facr',
|
||||
baseURL: process.env.REACT_APP_FACR_API_BASE_URL || '/api/v1/facr',
|
||||
timeout: parseInt(process.env.REACT_APP_FACR_API_TIMEOUT || '20000', 10),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -30,10 +30,12 @@ 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 baseOrigin = new URL(base).origin;
|
||||
const explicit = process.env.REACT_APP_API_BASE_URL || process.env.REACT_APP_API_URL || '';
|
||||
const origin = explicit
|
||||
? new URL(explicit, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin
|
||||
: (typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000');
|
||||
// Use URL constructor so query strings in `path` (e.g. /api/v1/x?t=123) are handled correctly
|
||||
return new URL(path, baseOrigin).toString();
|
||||
return new URL(path, origin).toString();
|
||||
}
|
||||
return path;
|
||||
} catch {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from './api';
|
||||
|
||||
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
// Use shared API_URL which already resolves to '/api/v1' under current origin
|
||||
|
||||
export interface FileInfo {
|
||||
id: number;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
import { API_URL as API_BASE_URL } from './api';
|
||||
|
||||
export interface NavigationItem {
|
||||
id?: number;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL as API_BASE_URL } from './api';
|
||||
import { IconType } from 'react-icons';
|
||||
import {
|
||||
FaRegClipboard,
|
||||
@@ -35,7 +36,7 @@ import {
|
||||
FaCube
|
||||
} from 'react-icons/fa';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:8080/api/v1';
|
||||
// Use shared API base URL
|
||||
|
||||
export interface PageElementConfig {
|
||||
id?: number;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { assetUrl } from '../utils/url';
|
||||
import { API_URL } from './api';
|
||||
|
||||
export interface RelatedClub {
|
||||
id: string;
|
||||
@@ -21,8 +22,7 @@ const resolveBackendUrl = (path: string): 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 origin = new URL(base).origin;
|
||||
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
return new URL(path, origin).toString();
|
||||
}
|
||||
return path;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from './api';
|
||||
import api, { API_URL } from './api';
|
||||
import { getArticles } from './articles';
|
||||
import { getPlayers } from './public';
|
||||
import { getUpcomingEvents } from './eventService';
|
||||
@@ -96,8 +96,7 @@ const resolveBackendUrl = (path: string): 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 origin = new URL(base).origin;
|
||||
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
return new URL(path, origin).toString();
|
||||
}
|
||||
return path;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from './api';
|
||||
import api, { API_URL } from './api';
|
||||
|
||||
export type YouTubeVideo = {
|
||||
video_id: string;
|
||||
@@ -38,12 +38,9 @@ export const getCachedYouTube = async (): Promise<YouTubeChannelPayload | null>
|
||||
// Helper: fetch static cached JSON from /cache/prefetch
|
||||
const fetchStaticYouTubeCache = async (): Promise<YouTubeChannelPayload | null> => {
|
||||
try {
|
||||
// Determine backend origin from env config similar to HomePage resolve logic
|
||||
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);
|
||||
// Force path to backend-exposed cache file
|
||||
u.pathname = '/cache/prefetch/youtube_channel.json';
|
||||
const resp = await fetch(u.toString(), { cache: 'no-cache' });
|
||||
const origin = new URL(API_URL, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
const url = `${origin}/cache/prefetch/youtube_channel.json`;
|
||||
const resp = await fetch(url, { cache: 'no-cache' });
|
||||
if (!resp.ok) return null;
|
||||
const data = (await resp.json()) as YouTubeChannelPayload;
|
||||
return sortByPublishedDate(data);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from './api';
|
||||
import api, { API_URL } from './api';
|
||||
|
||||
export interface ZoneramaPhoto {
|
||||
id: string;
|
||||
@@ -60,8 +60,7 @@ export async function saveAlbumToCache(albumLink: string, photoLimit: number = 5
|
||||
|
||||
// Helper to read the flat manifest produced by the prefetcher for fast grid rendering
|
||||
export async function getZoneramaManifest(): Promise<Array<{ id: string; album_id: string; src: string; local: string; page_url: string }>> {
|
||||
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, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
// New unified path for prefetched Zonerama items
|
||||
const url = `${origin}/cache/prefetch/zonerama_flat.json`;
|
||||
const res = await fetch(url, { cache: 'no-cache' });
|
||||
@@ -81,8 +80,7 @@ export async function getZoneramaManifestWithFallbacks(): Promise<Array<{ id: st
|
||||
const primary = await getZoneramaManifest();
|
||||
if (primary && primary.length > 0) return primary;
|
||||
|
||||
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, typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000').origin;
|
||||
|
||||
// 1b) Backward-compat removed - old path no longer used to avoid 404 errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user