Compare commits

...

3 Commits

Author SHA1 Message Date
f7c4ed9e3b docker fix backend url 2026-02-14 15:38:09 +00:00
bba77326f1 docker fix env name 2026-02-14 15:34:29 +00:00
f9665c92ce docker config 2026-02-14 15:16:45 +00:00
5 changed files with 8 additions and 13 deletions

View File

@@ -1,8 +1,7 @@
FROM docker.m.daocloud.io/library/node:21-alpine
FROM node:21-alpine
RUN apk add --no-cache bash
WORKDIR /app
COPY package*.json ./
RUN npm config set registry https://registry.npmmirror.com/
RUN npm install
COPY . .
EXPOSE 3000

View File

@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import './../styles/App.css';
import {getBackendHost} from "../utils/api";
const DebateConfiguration = ({ onCreateDebate, onViewSessions, onViewSettings, isGuest }) => {
const [formData, setFormData] = useState({
@@ -118,7 +119,7 @@ const DebateConfiguration = ({ onCreateDebate, onViewSessions, onViewSettings, i
if (provider === 'qwen') {
try {
// Call backend to get Qwen models (backend will fetch from Qwen API)
const qwenResponse = await fetch(`http://localhost:8000/models/${provider}`);
const qwenResponse = await fetch(`${getBackendHost()}/models/${provider}`);
if (qwenResponse.ok) {
const qwenData = await qwenResponse.json();
console.log('Backend Qwen models response:', qwenData); // Debug log

View File

@@ -1,5 +1,6 @@
import React, { useState, useEffect, useRef } from 'react';
import './../styles/App.css';
import {getBackendHost} from "../utils/api";
const DebateDisplay = ({ sessionId, onBackToConfig, isGuest }) => {
const [debateRounds, setDebateRounds] = useState([]);
@@ -42,7 +43,7 @@ const DebateDisplay = ({ sessionId, onBackToConfig, isGuest }) => {
.catch(err => console.error('Debate start error:', err));
// Connect to SSE endpoint for real-time updates
const es = new EventSource(`http://localhost:8000/debate/${sessionId}/stream`);
const es = new EventSource(`${getBackendHost()}/debate/${sessionId}/stream`);
setEventSource(es);
es.addEventListener('update', function(event) {

View File

@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import './../styles/App.css';
import {getBackendHost} from "../utils/api";
const SessionsList = ({ onLoadSession, onBackToConfig }) => {
const [sessions, setSessions] = useState([]);
@@ -13,7 +14,7 @@ const SessionsList = ({ onLoadSession, onBackToConfig }) => {
const fetchSessions = async () => {
try {
setLoading(true);
const response = await fetch('http://localhost:8000/sessions');
const response = await fetch(`${getBackendHost()}/sessions`);
if (!response.ok) {
throw new Error(`获取会话列表失败: ${response.statusText}`);

View File

@@ -8,12 +8,11 @@
import { getAccessTokenGlobal } from '../components/AuthProvider';
// Backend host: use CRA env var REACT_APP_BACKEND_HOST, or default to localhost.
let _backendHost = null;
export function getBackendHost() {
if (_backendHost !== null) return _backendHost;
_backendHost = process.env.REACT_APP_BACKEND_HOST || 'http://localhost:8000';
_backendHost = process.env.REACT_APP_DIALECTIC_BACKEND_HOST || 'http://localhost:8000';
return _backendHost;
}
@@ -21,14 +20,8 @@ export function setBackendHost(host) {
_backendHost = host;
}
/**
* Thin wrapper around fetch() that checks for the 503 "not configured"
* response and fires a global event when detected.
*/
export async function apiFetch(path, options = {}) {
const url = path.startsWith('http') ? path : `${getBackendHost()}${path}`;
// Attach Authorization header when a token is available
const token = getAccessTokenGlobal();
if (token) {
options.headers = { ...options.headers, Authorization: `Bearer ${token}` };