Files
aiagent/backend/tests/test_cors.py
renjianbo beff3fac8d fix: delete agent 500 error + dynamic personality + deployment guide
- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-29 01:17:21 +08:00

54 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
测试CORS配置
"""
import requests
# 测试CORS配置
def test_cors():
base_url = "http://101.43.95.130:8037"
# 测试OPTIONS请求CORS预检
print("测试CORS预检请求...")
headers = {
"Origin": "http://101.43.95.130:8038",
"Access-Control-Request-Method": "GET",
"Access-Control-Request-Headers": "Content-Type"
}
try:
response = requests.options(f"{base_url}/api/v1/tools/builtin", headers=headers)
print(f"OPTIONS请求状态码: {response.status_code}")
print(f"CORS头信息:")
for key, value in response.headers.items():
if key.lower().startswith('access-control'):
print(f" {key}: {value}")
except Exception as e:
print(f"OPTIONS请求失败: {e}")
# 测试GET请求
print("\n测试GET请求...")
headers = {
"Origin": "http://101.43.95.130:8038"
}
try:
response = requests.get(f"{base_url}/api/v1/tools/builtin", headers=headers)
print(f"GET请求状态码: {response.status_code}")
print(f"CORS头信息:")
for key, value in response.headers.items():
if key.lower().startswith('access-control'):
print(f" {key}: {value}")
if response.status_code == 200:
print(f"\n✅ 请求成功!")
data = response.json()
print(f"返回工具数量: {len(data)}")
else:
print(f"\n❌ 请求失败: {response.text}")
except Exception as e:
print(f"GET请求失败: {e}")
if __name__ == "__main__":
test_cors()