Skip to main content

Quick Start

This guide takes the shortest path to expose a cloud function as a directly callable HTTPS endpoint: create a function → configure a route → verify access. It takes about 5 minutes, and the commands and code can be copied as-is.

When you are done, you get an address like https://<domain>/hello that returns the function's response.

Before you start​

  • A CloudBase environment already exists. See Create an environment
  • Every environment comes with a default domain, which is fine for testing. For production, bind a custom domain

Step 1: Create a cloud function​

  1. Go to the CloudBase console and select the target environment
  2. In the left menu, choose "Cloud Functions", click "New cloud function", and name it helloWorld
  3. Replace the function code with the following:
exports.main = async function () {
return "Hello World!";
};
  1. Click "Save and install dependencies" and wait for the deployment to finish

For runtime and dependency options, see Cloud function quick start.

Step 2: Configure an HTTP route​

The HTTP Gateway matches requests by domain and path, then forwards them to a backend resource. A route is one such matching rule.

  1. Go to CloudBase console / HTTP Gateway and click "New" under Route Management
  2. Fill in the configuration as follows:
ItemValue
Associated resourceCloud function → helloWorld
DomainA default domain, or a connected custom domain
Trigger path/hello
  1. Click "OK". Creation takes about 3-5 minutes; the route takes effect when its status becomes "Normal"

Step 3: Verify access​

Once the route is active, the address is the domain plus the trigger path:

curl https://<your-domain>/hello
# Response: Hello World!

Open the same URL in a browser and it also shows Hello World!.

Using a custom domain

For public-facing services, bind a custom domain with ICP filing and configure an HTTPS certificate. See Custom domain. For limits on default domains, see Default domain access limits and interstitial page.

Next steps​