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:
@@ -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,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' },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user