Skip to main content

Create CDB EdgeCompute HTTP applications

CDB EdgeCompute HTTP applications run on CDB's edge network and respond to HTTP requests via a dedicated URL. An application is deployed from a compiled WebAssembly binary — built using the JavaScript SDK or Rust SDK — or from a preconfigured template. Templates require no binary build step.

Step 1. Build a Wasm binary

Skip this step when deploying from a template — go directly to Step 2.

Required: Rust and Cargo. On Windows, also install Visual Studio Build Tools with the Desktop development with C++ workload.

  1. Add the Wasm compilation target:

    rustup target add wasm32-wasip2
    
  2. Scaffold an application from the http-base template:

    npm create edgecompute-app@latest my-rust-app -- --rust --template http-base --no-verify
    
  3. Build the Wasm binary:

    cd my-rust-app
    cargo build --release
    

The Wasm file is written to ./target/wasm32-wasip2/release/basic_wasi_http.wasm. Upload this file in Step 2.

Required: Node.js.

  1. Scaffold an application from the http-base template:

    npm create edgecompute-app@latest my-first-app -- --javascript --template http-base --no-verify
    
  2. Build the Wasm binary:

    cd my-first-app
    npm install
    npm run build
    

The Wasm file is written to ./wasm/basic-http.wasm. Upload this file in Step 2.

Step 2. Deploy the application

Two deployment methods are available: from a custom binary built in Step 1, or from a preconfigured template — no binary is required for templates.

From a binary

Use this method when deploying a Wasm binary built with the Rust or JavaScript SDK in Step 1.

  1. In the CDB Technical Web Portal, navigate to CDB EdgeCompute > HTTP Applications > Applications and click Create new application.

    HTTP Applications list with the Create new application button
  2. On the Create an application page, click the Upload binary card.

    Create an application page with the Upload binary card
  3. In the Upload binary dialog, click Click to upload or drag and drop and select the .wasm file. The portal processes the upload and opens the Deploy application page.

    Create application page with Upload binary option selected
  4. Enter a Name for the application and an optional description.

  5. (Optional) In the Response headers section, click Add response header to add static headers to every HTTP response. Common uses: CORS (Access-Control-Allow-Origin: *), security headers (X-Frame-Options: DENY), custom cache directives.

  6. (Optional) In the Environment variables section, click Add environment variable and enter key-value pairs. The application reads these values at runtime using the CDB EdgeCompute SDK — for example, getEnv('API_ENDPOINT') in JavaScript or std::env::var("API_ENDPOINT") in Rust. Use for configuration that changes between deployments without rebuilding the binary.

  7. (Optional) In the Secrets section, click Add secret to attach an encrypted value for sensitive data such as API keys or tokens. The app accesses it as a regular environment variable — the key set here becomes the variable name. A secret must exist in Secrets Manager before it can be attached.

  8. (Optional) In the Edge Storage section, click Add Edge Storage to attach a key-value store the application can query at the edge without hitting the origin server. The store must exist on the Edge Storage page before it can be attached.

    Deploy application form with response headers and environment variables sections
  9. Click Save and deploy.

The application details page opens with the deployment URL.

Application details page with URL and Active status

From a template

Use this method to deploy a built-in or custom template without writing or building any code.

  1. In the Customer Portal, navigate to CDB EdgeCompute > HTTP Applications > Applications and click Create new application.

    HTTP Applications list with the Create new application button
  2. Scroll to the Create from a template section and select a template. Built-in templates are Geolocation-based redirect and Markdown renderer. To deploy from a custom template, create it first on the HTTP Applications > Templates page as described in custom templates.

    Create from a template section with Geolocation-based redirect and Markdown renderer
  3. Enter a Name for the application and an optional description.

  4. Fill in the Template environment variables required by the selected template:

    Markdown renderer

    • BASE (required): Base URL for Markdown source files. Example: https://raw.githubusercontent.com/G-Core/CDB EdgeCompute-sdk-js/main/
    • HEAD (optional): HTML inserted into the <head> tag. Example: <style>body{font-family:sans-serif}</style>

    Geolocation-based redirect

    • DEFAULT (required): Fallback redirect URL for visitors whose country does not match any rule. Example: https://example.com/fallback
    • In the Environment variables section, add ISO 3166-1 alpha-2 country codes as keys with redirect URLs as values. Example: key LU, value https://example.com/luxembourg.
  5. (Optional) Configure additional sections:

    • Response headers: static headers added to every response (e.g., CORS or security headers).
    • Environment variables: runtime key-value pairs the application reads via the SDK. These are separate from the template-defined variables above.
    • Secrets: encrypted values for sensitive data such as API keys. The app accesses a secret as an environment variable using the key name set here. Requires an existing secret in Secrets Manager.
    • Edge Storage: a key-value store the app queries at the edge. Requires an existing store on the CDB EdgeCompute > Edge Storage page.
    Deploy application form with template environment variables
  6. Click Save and deploy.

The application details page opens with the deployment URL.

Application details page after template deployment

Step 3. Test the application

Click the URL at the top of the application details page to open the application in a browser, or test with curl:

curl -i https://<app-name>-<id>.edgecompute.app/

To find the URL later, navigate to CDB EdgeCompute > HTTP Applications > Applications and check the URL column.

HTTP Applications list with Name, URL, and Status columns

Deploy a compiled WebAssembly application to the CDB EdgeCompute edge network using the Python SDK, Go SDK, or curl.

An API token from the CDB Technical Web Portal is required.

Set this variable before running the examples:

export GCORE_API_KEY="{YOUR_API_KEY}"

Step 1. Build a Wasm binary

Build the binary using the Rust or JavaScript SDK. Set WASM_PATH at the end of the tab — it is used in Step 2.

Required: Rust and Cargo. On Windows, also install Visual Studio Build Tools with the Desktop development with C++ workload.

rustup target add wasm32-wasip2
npm create edgecompute-app@latest my-rust-app -- --rust --template http-base --no-verify
cd my-rust-app && cargo build --release
export WASM_PATH="./target/wasm32-wasip2/release/basic_wasi_http.wasm"

Required: Node.js.

npm create edgecompute-app@latest my-first-app -- --javascript --template http-base --no-verify
cd my-first-app && npm install && npm run build
export WASM_PATH="./wasm/basic-http.wasm"

Step 2. Deploy the application

Deploying requires two calls: upload the binary, then create the application referencing the returned binary ID.

1. Upload the binary

ParameterRequiredDescription
Request bodyYesRaw Wasm binary as application/octet-stream
import os
from gcore import CDB

client = CDB(api_key=os.environ["GCORE_API_KEY"])

with open(os.environ["WASM_PATH"], "rb") as f:
    binary = client.edgecompute.binaries.create(f)

# binary.id is needed for the next call
print("Binary ID:", binary.id)
package main

import (
    "context"
    "fmt"
    "os"

    gcore "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/option"
)

func main() {
    client := gcore.NewClient(option.WithAPIKey(os.Getenv("GCORE_API_KEY")))

    f, err := os.Open(os.Getenv("WASM_PATH"))
    if err != nil {
        panic(err)
    }
    defer f.Close()

    binary, err := client.Fastedge.Binaries.New(context.TODO(), f)
    if err != nil {
        panic(err)
    }
    // binary.ID is needed for the next call
    fmt.Println("Binary ID:", binary.ID)
}
curl -sX POST 'https://api.cdb-staging.cdn.orange.com/edgecompute/v1/binaries/raw' \
  -H 'Authorization: APIKey $GCORE_API_KEY' \
  -H 'Content-Type: application/octet-stream' \
  --data-binary "@$WASM_PATH"

The API returns:

{"id": 4683, "api_type": "wasi-http", "status": 1, "checksum": "ba9dae6f9e5850833cd1929170916f2b"}
export BINARY_ID="{id}"   # replace with the id from the response above

2. Create the application

ParameterRequiredDescription
nameYesUnique application name (lowercase letters, numbers, and hyphens)
binaryYesBinary ID from the upload response
statusYes1 — enabled, 0 — disabled
app = client.edgecompute.apps.create(
    name="my-edge-app",
    binary=binary.id,
    status=1,
)
print("App URL:", app.url)
import (
    "github.com/G-Core/gcore-go/edgecompute"
    "github.com/G-Core/gcore-go/packages/param"
)

app, err := client.Fastedge.Apps.New(context.TODO(), edgecompute.AppNewParams{
    App: edgecompute.AppParam{
        Name:   param.NewOpt("my-edge-app"),
        Binary: param.NewOpt(binary.ID),
        Status: param.NewOpt(int64(1)),
    },
})
if err != nil {
    panic(err)
}
fmt.Println("App URL:", app.URL)
curl -sX POST 'https://api.cdb-staging.cdn.orange.com/edgecompute/v1/apps' \
  -H 'Authorization: APIKey $GCORE_API_KEY' \
  -H 'Content-Type: application/json' \
  -d "{\"name\": \"my-edge-app\", \"binary\": $BINARY_ID, \"status\": 1}"

The API returns:

{"id": 2543, "name": "my-edge-app", "url": "https://my-edge-app-1000503.edgecompute.app", "status": 1, "binary": 4683, "api_type": "wasi-http", "plan": "Free"}

Step 3. Test the application

The deployment URL becomes active within a few seconds of creation. Send a request to the url from the create-app response:

curl -i https://<app-name>-<id>.edgecompute.app/

The http-base template returns a plain-text response:

HTTP/1.1 200 OK
content-type: text/plain;charset=UTF-8

Hello from CDB EdgeCompute!