Spaces:
Running
fix: set DEER_FLOW_TRUSTED_ORIGINS for Next.js — fixes Application error
Browse filesThe pre-built frontend image (af6e48cc) uses an older gateway-config.ts
that has NO defaults in production mode. Both DEER_FLOW_INTERNAL_GATEWAY_BASE_URL
and DEER_FLOW_TRUSTED_ORIGINS must be set explicitly — otherwise zod
schema validation throws, getServerSideUser() returns {tag:"config_error"},
workspace/auth layouts throw new Error(), and Next.js shows
"Application error: a server-side exception has occurred" on every page.
We were setting INTERNAL_GATEWAY_BASE_URL but not TRUSTED_ORIGINS.
TRUSTED_ORIGINS set to localhost:3000 + localhost:7860 + SPACE_HOST.
With this fix the SSR no longer throws. /workspace redirects to /login
(unauthenticated) or /setup (first boot). /setup renders the admin
account creation form.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@@ -390,11 +390,21 @@ if [ "$ready" != "true" ]; then
|
|
| 390 |
fi
|
| 391 |
echo "Backend ready."
|
| 392 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
# ── Start frontend (Next.js) ──────────────────────────────────────
|
| 394 |
echo "Starting Next.js frontend on port $FRONTEND_PORT..."
|
| 395 |
(
|
| 396 |
cd "$APP_DIR/frontend" && \
|
| 397 |
DEER_FLOW_INTERNAL_GATEWAY_BASE_URL="http://127.0.0.1:$BACKEND_PORT" \
|
|
|
|
| 398 |
PORT="$FRONTEND_PORT" \
|
| 399 |
NODE_OPTIONS="--require $APP_DIR/cloudflare-proxy.js" \
|
| 400 |
node_modules/.bin/next start -p "$FRONTEND_PORT" \
|
|
|
|
| 390 |
fi
|
| 391 |
echo "Backend ready."
|
| 392 |
|
| 393 |
+
# ── Build DEER_FLOW_TRUSTED_ORIGINS ───────────────────────────────
|
| 394 |
+
# Required in production mode by the pre-built frontend image (af6e48cc):
|
| 395 |
+
# gateway-config.ts has NO defaults in prod — both vars must be explicit
|
| 396 |
+
# or zod schema fails → config_error → "Application error" on every page.
|
| 397 |
+
TRUSTED_ORIGINS="http://localhost:3000,http://localhost:7860"
|
| 398 |
+
if [ -n "${SPACE_HOST:-}" ]; then
|
| 399 |
+
TRUSTED_ORIGINS="$TRUSTED_ORIGINS,https://$SPACE_HOST"
|
| 400 |
+
fi
|
| 401 |
+
|
| 402 |
# ── Start frontend (Next.js) ──────────────────────────────────────
|
| 403 |
echo "Starting Next.js frontend on port $FRONTEND_PORT..."
|
| 404 |
(
|
| 405 |
cd "$APP_DIR/frontend" && \
|
| 406 |
DEER_FLOW_INTERNAL_GATEWAY_BASE_URL="http://127.0.0.1:$BACKEND_PORT" \
|
| 407 |
+
DEER_FLOW_TRUSTED_ORIGINS="$TRUSTED_ORIGINS" \
|
| 408 |
PORT="$FRONTEND_PORT" \
|
| 409 |
NODE_OPTIONS="--require $APP_DIR/cloudflare-proxy.js" \
|
| 410 |
node_modules/.bin/next start -p "$FRONTEND_PORT" \
|