Skip to main content

Access via HTTP

After creating the cloud hosting service, it will provide you with an HTTPS access domain name for the service. You can access your deployed service via this domain name.

All cloud hosting services provide a default domain name. However, in a production environment scenario, we strongly recommend configuring a custom domain via HTTP Access Service. When accessing the service via HTTP, you can enable capabilities such as service authentication and custom domains.

Create Service

Creating a service on Cloud Hosting requires meeting the following conditions:

  • Access via the public internet
  • Publicly accessible URL

By default, cloud hosting provides public internet access, and the default domain name has no authentication. If you need to disable public domain access, after deploying the service, navigate to Service Settings -> Network Access and turn off the public network switch.

Service Domain

Public Domain

Cloud hosting assigns a public domain to each service, which you can use to access your cloud hosting service. You can also turn off the public network switch in Service Settings -> Network Access.

We assume the default domain name for the created service is: https://demo.ap-shanghai.run.tcloudbase.com

Internal Domain

Cloud hosting also assigns an internal domain to each service, which is disabled by default. You can turn on the public network switch in Service Settings -> Network Access.

Internal Domain applies to the following scenarios:

  • Inter-service access via HTTP
  • Replicas directly access each other via gRPC
  • Inter-service access via other layer 4 protocols, etc.

Access via CURL

curl --location --request GET 'https://demo.ap-shanghai.run.tcloudbase.com'

Access via PHP-CURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.ap-shanghai.run.tcloudbase.com',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Access via fetch

fetch("https://demo.ap-shanghai.run.tcloudbase.com", {
method: "GET",
redirect: "follow",
})
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Access via Browser JS-XHR

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("GET", "https://demo.ap-shanghai.run.tcloudbase.com");
xhr.send();

Access via QQ Mini Program

qq.request({
url: "https://demo.ap-shanghai.run.tcloudbase.com",
success(res) {
console.log(res.data);
},
});

Access via UNI-APP

uni.request({
url: "https://demo.ap-shanghai.run.tcloudbase.com",
success: function (res) {
console.log(res.data);
},
});