Compare commits
3 Commits
bd03492ef4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f7c4ed9e3b | |||
| bba77326f1 | |||
| f9665c92ce |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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}` };
|
||||
|
||||
Reference in New Issue
Block a user