|
1 | 1 | #!/bin/sh |
2 | 2 | set -e |
3 | 3 |
|
4 | | -BASEPATH_PLACEHOLDER="/__NEXT_BASEPATH_PLACEHOLDER__" |
5 | | -BASEPATH_PLACEHOLDER_ESCAPED="\\\\\\\\/__NEXT_BASEPATH_PLACEHOLDER__" |
6 | | -API_URL_PLACEHOLDER="__NEXT_API_URL_PLACEHOLDER__" |
7 | | -WS_URL_PLACEHOLDER="__NEXT_WS_URL_PLACEHOLDER__" |
| 4 | +echo "Starting LLM Gateway Frontend" |
| 5 | +echo " basePath: /llm-admin (built-in)" |
| 6 | +echo " API_URL: ${NEXT_PUBLIC_API_URL:-auto-detect from window.location}" |
| 7 | +echo " WS_URL: ${NEXT_PUBLIC_WS_URL:-auto-detect from window.location}" |
8 | 8 |
|
9 | | -if [ -n "$BASE_PATH" ]; then |
10 | | - echo "Configuring basePath: $BASE_PATH" |
11 | | - ESCAPED_BASE_PATH=$(echo "$BASE_PATH" | sed 's|/|\\/|g') |
12 | | - sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" /app/server.js 2>/dev/null || true |
13 | | - sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" /app/.next/routes-manifest.json 2>/dev/null || true |
14 | | - # Escaped version first (for regex patterns in JSON) |
15 | | - find /app/.next/static -type f -name "*.json" -exec sed -i "s|${BASEPATH_PLACEHOLDER_ESCAPED}|${ESCAPED_BASE_PATH}|g" {} + 2>/dev/null || true |
16 | | - find /app/.next/static -type f \( -name "*.js" -o -name "*.json" \) -exec sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" {} + 2>/dev/null || true |
17 | | - find /app/.next/server -type f \( -name "*.html" -o -name "*.rsc" -o -name "*.meta" -o -name "*.body" \) -exec sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" {} + 2>/dev/null || true |
18 | | - find /app/.next/server -type f -name "*client-reference-manifest.js" -exec sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" {} + 2>/dev/null || true |
19 | | - # Also handle prerender manifests and action manifests |
20 | | - find /app/.next -type f -name "*.json" -exec sed -i "s|${BASEPATH_PLACEHOLDER}|${BASE_PATH}|g" {} + 2>/dev/null || true |
21 | | -else |
22 | | - echo "No BASE_PATH set, running at root path" |
23 | | - sed -i "s|${BASEPATH_PLACEHOLDER}||g" /app/server.js 2>/dev/null || true |
24 | | - sed -i "s|${BASEPATH_PLACEHOLDER}||g" /app/.next/routes-manifest.json 2>/dev/null || true |
25 | | - # Escaped version first (for regex patterns in JSON) |
26 | | - find /app/.next/static -type f -name "*.json" -exec sed -i "s|${BASEPATH_PLACEHOLDER_ESCAPED}||g" {} + 2>/dev/null || true |
27 | | - find /app/.next/static -type f \( -name "*.js" -o -name "*.json" \) -exec sed -i "s|${BASEPATH_PLACEHOLDER}||g" {} + 2>/dev/null || true |
28 | | - find /app/.next/server -type f \( -name "*.html" -o -name "*.rsc" -o -name "*.meta" -o -name "*.body" \) -exec sed -i "s|${BASEPATH_PLACEHOLDER}||g" {} + 2>/dev/null || true |
29 | | - find /app/.next/server -type f -name "*client-reference-manifest.js" -exec sed -i "s|${BASEPATH_PLACEHOLDER}||g" {} + 2>/dev/null || true |
30 | | - # Also handle prerender manifests and action manifests |
31 | | - find /app/.next -type f -name "*.json" -exec sed -i "s|${BASEPATH_PLACEHOLDER}||g" {} + 2>/dev/null || true |
32 | | -fi |
33 | | - |
34 | | -API_URL="${NEXT_PUBLIC_API_URL:-http://localhost:8000}" |
35 | | -echo "Configuring API URL: $API_URL" |
36 | | -find /app/.next/static -type f -name "*.js" -exec sed -i "s|${API_URL_PLACEHOLDER}|${API_URL}|g" {} + 2>/dev/null || true |
37 | | - |
38 | | -WS_URL="${NEXT_PUBLIC_WS_URL:-ws://localhost:8000}" |
39 | | -echo "Configuring WebSocket URL: $WS_URL" |
40 | | -find /app/.next/static -type f -name "*.js" -exec sed -i "s|${WS_URL_PLACEHOLDER}|${WS_URL}|g" {} + 2>/dev/null || true |
41 | | - |
42 | | -echo "Configuration complete" |
43 | 9 | exec "$@" |
0 commit comments