应用 - 网络
设置自定义域名
将你的网站与自定义域名集成。速率限制为每 5 分钟 10 次更改,每 24 小时 50 次更改。
POST
/
v2
/
apps
/
{app_id}
/
network
/
custom
设置自定义域名
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/custom \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"custom": "<string>"
}
'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"
payload = { "custom": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({custom: '<string>'})
};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/custom', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/custom",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'custom' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"
payload := strings.NewReader("{\n \"custom\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"custom\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"custom\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success"
}
使用此路由至少需要 Standard 套餐。
同一账户可以将一个域名绑定到多个应用(负载均衡):Standard 最多 2 个应用,Pro 最多 5 个,Enterprise 最多 10 个。参见 列出负载均衡器。
失败时,响应会包含一个错误
参数
应用的 ID。你可以在应用仪表盘的 URL 中找到它。
要绑定的完全限定域名,或使用
@ 移除应用当前的自定义域名。它不能是 Square Cloud 域名(squareweb.app、squarecloud.app……)。响应
指示调用是否成功。成功时为
success,否则为 error。code:
| Status | Code | 含义 |
|---|---|---|
400 | REGEX_VALIDATION | 该域名不是有效的完全限定域名。 |
400 | RESERVED_DOMAIN | Square Cloud 域名不能用作自定义域名。 |
403 | UPGRADE_REQUIRED | 当前套餐不包含自定义域名(需要 Standard、Pro 或 Enterprise)。 |
403 | LOAD_BALANCER_LIMIT_REACHED | 已达到该套餐在此域名上的应用数量上限。 |
409 | DOMAIN_ALREADY_EXISTS | 该域名已绑定到另一账户拥有的应用。 |
502 | DNS_FAILED | 域名绑定在边缘提供商处失败。 |
{
"status": "success"
}
⌘I
设置自定义域名
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/network/custom \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"custom": "<string>"
}
'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"
payload = { "custom": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({custom: '<string>'})
};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/network/custom', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/network/custom",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'custom' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/network/custom"
payload := strings.NewReader("{\n \"custom\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"custom\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/network/custom")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"custom\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success"
}

