refactor(aria): standardize API URL — VITE_API_URL=api.bcos.dev/aria

Single VITE_API_URL replaces apiUrl+authUrl. Gateway URL for auth calls
is derived at runtime via apiUrl.replace(/\/aria$/, '').

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-25 14:40:10 -04:00
parent 2c957fb072
commit b0121c9f44
2 changed files with 6 additions and 14 deletions
+2 -9
View File
@@ -1,19 +1,12 @@
#!/bin/sh
set -e
# Inject runtime config from environment variables into the built SPA.
# This file is written to /app/dist/config.js and loaded by index.html
# BEFORE the Vite bundle — so window.__APP_CONFIG__ is available at startup.
#
# Add new config values here and in src/lib/api.ts Window interface.
cat > /app/dist/config.js <<EOF
window.__APP_CONFIG__ = {
apiUrl: '${VITE_API_URL:-http://localhost:8080}',
authUrl: '${VITE_AUTH_URL:-http://localhost:8082}'
apiUrl: '${VITE_API_URL:-http://localhost:8017}'
};
EOF
echo "config.js: apiUrl=${VITE_API_URL:-http://localhost:8080}"
echo "config.js: apiUrl=${VITE_API_URL:-http://localhost:8017}"
exec "$@"
+4 -5
View File
@@ -4,21 +4,20 @@ declare global {
interface Window {
__APP_CONFIG__?: {
apiUrl?: string;
authUrl?: string;
};
}
}
const API_BASE = window.__APP_CONFIG__?.apiUrl || 'http://localhost:8017';
const AUTH_BASE = window.__APP_CONFIG__?.authUrl || 'http://localhost:8082';
const ariaApiUrl = window.__APP_CONFIG__?.apiUrl || 'http://localhost:8017';
const gatewayUrl = ariaApiUrl.replace(/\/aria$/, '');
const api = axios.create({
baseURL: API_BASE,
baseURL: ariaApiUrl,
headers: { 'Content-Type': 'application/json' },
});
export const authApi = axios.create({
baseURL: AUTH_BASE,
baseURL: gatewayUrl,
headers: { 'Content-Type': 'application/json' },
});