Skip to content

Commit 165a34c

Browse files
fix: replace hardcoded localhost API URLs with relative paths
All client hooks were falling back to http://localhost:3001/api which resolves to the user's browser machine, not the server. Changed to /api (relative) so requests go to the same origin in production, while Vite's dev proxy still handles local dev. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 98040eb commit 165a34c

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

client/src/modules/maritime/hooks/useMaritimeSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function useMaritimeSnapshot() {
2828
return useQuery<MaritimeSnapshotResponse>({
2929
queryKey: ['maritime', 'snapshot'],
3030
queryFn: async () => {
31-
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
31+
const API_URL = import.meta.env.VITE_API_URL || '/api';
3232
const res = await fetch(`${API_URL}/maritime/snapshot`);
3333
if (!res.ok) {
3434
throw new Error('Network error fetching maritime snapshot');

client/src/modules/maritime/hooks/useVesselDetail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useQuery } from '@tanstack/react-query';
22
import type { VesselState } from './useMaritimeSnapshot';
33

4-
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
4+
const API_URL = import.meta.env.VITE_API_URL || '/api';
55

66
/**
77
* Fetches full vessel detail — including route history — for the selected vessel.

client/src/modules/monitor/hooks/useGPSJammingData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect } from 'react';
22
import { useGPSJammingStore } from '../gpsJamming.store';
33

4-
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
4+
const API_BASE = import.meta.env.VITE_API_URL || '/api';
55

66
/**
77
* Hook to fetch and manage GPS jamming data

client/src/modules/monitor/hooks/useGulfWatchAlerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useQuery } from '@tanstack/react-query';
22

3-
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
3+
const API_BASE = import.meta.env.VITE_API_URL || '/api';
44

55
export interface AlertDescription {
66
ar: string;

client/src/modules/monitor/hooks/useMilitaryBases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useQuery } from '@tanstack/react-query';
22

3-
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
3+
const API_BASE = import.meta.env.VITE_API_URL || '/api';
44

55
export type BaseCategory = 'air' | 'naval' | 'ground' | 'hq';
66

client/src/modules/monitor/hooks/useRocketAlerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useQuery } from '@tanstack/react-query';
22

3-
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:3001/api';
3+
const API_BASE = import.meta.env.VITE_API_URL || '/api';
44

55
export interface RocketAlertItem {
66
name: string;

client/src/modules/osint/hooks/useIntelBrief.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface IntelBriefResponse {
1414
export function useIntelBrief() {
1515
return useMutation({
1616
mutationFn: async (reqData: IntelBriefRequest) => {
17-
const res = await fetch('http://localhost:3001/api/geo/intel-brief', {
17+
const res = await fetch('/api/geo/intel-brief', {
1818
method: 'POST',
1919
headers: {
2020
'Content-Type': 'application/json',

client/src/modules/osint/hooks/useOsintNews.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function useOsintNews(lat: number, lon: number, category: string, enabled
2121
queryKey: ['osint-news', Math.round(lat), Math.round(lon), category], // Round to 1 degree to avoid over-fetching
2222
queryFn: async () => {
2323
const res = await fetch(
24-
`http://localhost:3001/api/geo/news?lat=${lat}&lon=${lon}&category=${encodeURIComponent(category)}`,
24+
`/api/geo/news?lat=${lat}&lon=${lon}&category=${encodeURIComponent(category)}`,
2525
);
2626
if (!res.ok) {
2727
throw new Error('Failed to fetch OSINT news');

0 commit comments

Comments
 (0)