דילוג לתוכן
אומת

חיבור דומיין

הפניית אחד הדומיינים של החשבון אל הפרויקט של המפתח הזה דרך DNS, עם מפתח ברמת App.

agent_domain_connect היא קריאה ברמת פרויקט: בניגוד לכל כתיבה אחרת בפרק הזה, היא לא מקבלת app_id. הפרויקט שהיא מפנה אליו דומיין הוא זה שממנו המפתח עצמו הונפק, ולכן המתכון הזה צריך מפתח App (שנוצר בלשונית ה-API של הפרויקט עצמו), לא מפתח Account. agent_domain_list היא קריאת הליווי, הדומיינים של החשבון עצמו, כך שתמיד שולחים שם שהחשבון באמת מחזיק בו.

שיטות

POST/cpi/agent_domain_list
user

Domains: list

List the account's registered domains (name, status, which app each is attached to). Use this BEFORE asking the user to type a domain: if they say 'connect one of my domains', call this and present the options.

POST/cpi/agent_domain_connect
user

Domains: connect to this VPS

Point one of the account's own domains (from agent_domain_list) at THIS project's VPS via DNS. Optional subdomain (e.g. 'app' -> app.example.com); omit to use the apex. Prefer a subdomain unless the user explicitly wants the apex. Attaching replaces any existing record on that exact hostname.

צריך מפתח App, לא מפתח Account

שתי השיטות פותרות uid מהמפתח שאתם שולחים, כמו בכל מקום אחר, אבל agent_domain_connect פותרת ממנו גם app_id, ורק מפתח שהונפק מלשונית ה-API של פרויקט נושא כזה. קריאה עם מפתח Account עונה -1, 'no app is bound to this action', עוד לפני שהיא מסתכלת על הדומיין. ראו אימות לשלושת היקפי המפתחות.

הדרכה צעד אחר צעד

מפרטים את הדומיינים של החשבון

אין שדות מלבד המפתח. כל שורה היא דומיין אחד שהחשבון רשם דרך Xuda או חיבר בהעברת שרתי השמות שלו, לאיזה פרויקט שהוא מפנה כרגע (אם בכלל), ו- status משלו.

curl -s https://xuda.ai/cpi/agent_domain_list \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY"}'
const res = await fetch('https://xuda.ai/cpi/agent_domain_list', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY' }),
});
const { code, data } = await res.json();
if (code > 0) for (const d of data.domains) console.log(d.domain, d.status, d.attached_app_id);
import requests

res = requests.post(
    'https://xuda.ai/cpi/agent_domain_list',
    json={'api_key': 'YOUR_API_KEY'},
)
body = res.json()
if body['code'] > 0:
    for d in body['data']['domains']:
        print(d['domain'], d['status'], d['attached_app_id'])

2. מפנים אחד אל הפרויקט של המפתח הזה

domain חייב להיות אחד מהשמות שהקריאה הקודמת החזירה. subdomain הוא אופציונלי ואינו קשור לשם הפרויקט של מפתח ה-App, זו תווית על הדומיין ("app" עבור app.example.com); משמיטים אותו כדי להפנות את שורש הדומיין במקום. הרצה חוזרת עם subdomain אחר לא פוגעת בשם מארח שכבר צירפתם, רק הרשומה של שם המארח המדויק הזה מוחלפת.

curl -s https://xuda.ai/cpi/agent_domain_connect \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_APP_API_KEY","domain":"example.com","subdomain":"app"}'
const res = await fetch('https://xuda.ai/cpi/agent_domain_connect', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_APP_API_KEY',
    domain: 'example.com',
    subdomain: 'app',
  }),
});
const { code, data } = await res.json();
if (code > 0) console.log(data.record.type, data.record.name, data.record.target);
import requests

res = requests.post(
    'https://xuda.ai/cpi/agent_domain_connect',
    json={'api_key': 'YOUR_APP_API_KEY', 'domain': 'example.com', 'subdomain': 'app'},
)
body = res.json()
if body['code'] > 0:
    print(body['data']['record']['type'], body['data']['record']['name'], body['data']['record']['target'])

התשובה

agent_domain_list מקצצת כל מסמך דומיין שמור לארבעה שדות:

json
{
  "code": 1,
  "data": {
    "count": 2,
    "domains": [
      {
        "domain": "example.com",
        "status": "active",
        "connection_type": "registered",
        "attached_app_id": null
      },
      {
        "domain": "example.org",
        "status": "active",
        "connection_type": "connected",
        "attached_app_id": "app_5d9e21"
      }
    ]
  }
}

connection_type הוא registered לדומיין שנקנה דרך Xuda (Xuda היא הרשם וגם ה- DNS) או connected לדומיין שנרשם במקום אחר ושרתי השמות שלו מועברים ל-Xuda (DNS בלבד, הרישום נשאר במקומו). שניהם עובדים באותו אופן עבור agent_domain_connect.

agent_domain_connect עונה עם רשומת ה-DNS שהיא כתבה בפועל:

json
{
  "code": 1,
  "data": {
    "ok": true,
    "record": {
      "type": "A",
      "name": "app.example.com",
      "target": "203.0.113.42",
      "proxied": true,
      "ssl_mode": "full"
    }
  }
}

type תלוי בסוג הפרויקט שהמפתח מוגבל אליו, ולא במשהו שאתם שולחים: פרויקט VPS מקבל רשומת A אל ה-IP שלו (או AAAA ב-VM של farm בלי IPv4 ציבורי), כל השאר מקבל CNAME אל כתובת הגישה של הפרויקט עצמו. כל רשומה עוברת דרך הפרוקסי של Cloudflare (proxied: true), כך שהמבקר מקבל HTTPS בקצה בכל מקרה. ssl_mode נקבע רק במסלול ה-VPS, שבו Xuda גם בודקת וקובעת את מצב ה-SSL של המקור באזור (full, strict או flexible); הוא חוזר null ליעד CNAME, ה-Universal SSL של Cloudflare עצמה מכסה את המקרה הזה בלי הגדרת אזור לדווח עליה.

שגיאות

הבא