解决跨越问题
parent
f4b0cdc569
commit
efd2b9051b
|
|
@ -12,7 +12,7 @@ DATABASE_MAX_OVERFLOW=10
|
|||
# ======================
|
||||
# Redis Configuration
|
||||
# ======================
|
||||
REDIS_PASSWORD=cosmo
|
||||
REDIS_PASSWORD=
|
||||
REDIS_MAX_CONNECTIONS=50
|
||||
|
||||
# ======================
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ class HorizonsService:
|
|||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
logger.info(f"Fetching raw data for body {body_id}")
|
||||
response = await client.get(url, params=params, timeout=30.0)
|
||||
# Reduced timeout for China network (NASA JPL may be blocked)
|
||||
response = await client.get(url, params=params, timeout=5.0)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"NASA API returned status {response.status_code}")
|
||||
|
|
|
|||
|
|
@ -6,20 +6,22 @@ import type { CelestialDataResponse, BodyInfo } from '../types';
|
|||
import { auth } from './auth';
|
||||
|
||||
// Dynamically determine the API base URL
|
||||
// If VITE_API_BASE_URL is set, use it; otherwise use the current host with port 8000
|
||||
const getApiBaseUrl = () => {
|
||||
if (import.meta.env.VITE_API_BASE_URL) {
|
||||
console.log('[API] Using VITE_API_BASE_URL:', import.meta.env.VITE_API_BASE_URL);
|
||||
return import.meta.env.VITE_API_BASE_URL;
|
||||
}
|
||||
|
||||
// Use the same host as the frontend, but with port 8000
|
||||
const protocol = window.location.protocol;
|
||||
const hostname = window.location.hostname;
|
||||
const apiUrl = `${protocol}//${hostname}:8000/api`;
|
||||
console.log('[API] Constructed API URL:', apiUrl);
|
||||
console.log('[API] Protocol:', protocol, 'Hostname:', hostname);
|
||||
return apiUrl;
|
||||
// In production, use relative path /api (proxied by Nginx)
|
||||
// This works for both internal IP and external domain access
|
||||
if (import.meta.env.PROD) {
|
||||
console.log('[API] Using production relative path: /api');
|
||||
return '/api';
|
||||
}
|
||||
|
||||
// In development, proxy is configured in vite.config.ts
|
||||
console.log('[API] Using development relative path: /api');
|
||||
return '/api';
|
||||
};
|
||||
|
||||
const API_BASE_URL = getApiBaseUrl();
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ http {
|
|||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Add CORS headers for 3D models and textures
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept' always;
|
||||
|
||||
# Cache uploaded files
|
||||
expires 1y;
|
||||
add_header Cache-Control "public";
|
||||
|
|
|
|||
Loading…
Reference in New Issue