fix: 修正 generate 頁面硬編碼 API URL 問題
- 🔧 修正 app/generate/page.tsx 中的硬編碼端口 - 🔧 修正 useSentenceAnalysis.ts Hook 中的硬編碼端口 - ✅ 統一使用 API_CONFIG.BASE_URL 配置 - ✅ 修正 "Failed to fetch" 錯誤 - ⚙️ 確保 AI 句子分析功能正常運作 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fc517d8cd2
commit
b45d119d78
|
|
@ -8,6 +8,7 @@ import { useToast } from '@/components/shared/Toast'
|
|||
import { flashcardsService } from '@/lib/services/flashcards'
|
||||
import { compareCEFRLevels, getLevelIndex, getTargetLearningRange } from '@/lib/utils/cefrUtils'
|
||||
import { BluePlayButton } from '@/components/shared/BluePlayButton'
|
||||
import { API_CONFIG } from '@/lib/config/api'
|
||||
import Link from 'next/link'
|
||||
|
||||
// 常數定義
|
||||
|
|
@ -51,7 +52,7 @@ function GenerateContent() {
|
|||
setIsAnalyzing(true)
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:5008/api/ai/analyze-sentence', {
|
||||
const response = await fetch(`${API_CONFIG.BASE_URL}/api/ai/analyze-sentence`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useState } from 'react'
|
||||
import { useToast } from '@/components/shared/Toast'
|
||||
import { getLevelIndex } from '@/lib/utils/cefrUtils'
|
||||
import { API_CONFIG } from '@/lib/config/api'
|
||||
|
||||
interface AnalysisResult {
|
||||
originalText: string
|
||||
|
|
@ -19,7 +20,7 @@ export function useSentenceAnalysis() {
|
|||
setIsAnalyzing(true)
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:5008/api/ai/analyze-sentence', {
|
||||
const response = await fetch(`${API_CONFIG.BASE_URL}/api/ai/analyze-sentence`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
|
|
|||
Loading…
Reference in New Issue