> For the complete documentation index, see [llms.txt](https://wanitools.gitbook.io/wani-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wanitools.gitbook.io/wani-docs/boost-bot-v2/custom-domain.md).

# Custom Domain

In this section, you will have a detailed explanation on how to link your own custom domain to use for **Redeem** and **Live Stock** website.

Follow these steps to point your custom domain to our API endpoint at `api.woojiee.lol`.

## How It Works

Instead of sharing raw API links like `api.woojiee.lol/boostbotv/stock/<id>`, you can use a **Cloudflare Worker** to proxy your own domain (e.g. `shop.yourdomain.com`) to the panel. Customers will see clean, branded URLs.

| Your Custom Domain                     | → Panel API       |
| -------------------------------------- | ----------------- |
| `shop.yourdomain.com/stock`            | Live Stock page   |
| `shop.yourdomain.com/redeem`           | Redeem form       |
| `shop.yourdomain.com/orders/{orderId}` | Order detail page |

## Requirements

* A domain you own (can be purchased on Namecheap, Cloudflare, etc.)
* A **Cloudflare account** (free plan is enough)
* Your **Discord Bot ID** (the bot you set up with Boost Bot)

{% stepper %}
{% step %}

## Add Your Domain to Cloudflare

1. Go to [cloudflare.com](https://cloudflare.com/) and log in.
2. Click **Add a Site** → enter your domain → choose the **Free** plan.
3. Cloudflare will show you 2 nameservers. Go to your domain registrar and replace the nameservers with the ones Cloudflare gives you.
4. Wait a few minutes for DNS to propagate.
   {% endstep %}

{% step %}

## Create a Cloudflare Worker

1. In Cloudflare dashboard, go to **Workers & Pages** → **Create** → **Hello World** → **Deploy**.
2. Click **Edit Code** and replace all existing code with the Worker script below.
3. Change the `BOT_ID` value to **your Discord Bot ID**.
4. Click **Deploy**.

```js
const BOT_ID = "Your_Bot_ID";            // <-- your Discord bot id
const API_BASE = "https://api.woojiee.lol/boostbot"; // customer PAGES

async function proxy(request, targetUrl) {
  try {
    const isBodyless = request.method === "GET" || request.method === "HEAD";
    const init = {
      method: request.method,
      headers: request.headers,
      body: isBodyless ? undefined : request.body,
    };
    if (init.body) init.duplex = "half";
    const resp = await fetch(targetUrl, init);
    return new Response(resp.body, { status: resp.status, headers: resp.headers });
  } catch (_) {
    return new Response("Page Offline", { status: 502 });
  }
}

export default {
  async fetch(request) {
    const url = new URL(request.url);
    const path = url.pathname;
    
    if (path.startsWith("/boostbot/")) {
      const apiOrigin = new URL(API_BASE).origin;
      return proxy(request, `${apiOrigin}${path}${url.search}`);
    }

    if (path.startsWith("/assets/")) {
      const apiOrigin = new URL(API_BASE).origin;
      return proxy(request, `${apiOrigin}${path}${url.search}`);
    }

    if (path === "/" || path === "/stock") {
      return proxy(request, `${API_BASE}/stock/${BOT_ID}${url.search}`);
    }

    if (path === "/redeem") {
      return proxy(request, `${API_BASE}/redeem/${BOT_ID}${url.search}`);
    }
    
    if (path.startsWith("/orders/")) {
      const orderId = path.split("/orders/")[1].replace(/\/+$/, "");
      if (orderId) return proxy(request, `${API_BASE}/orders/${BOT_ID}/${orderId}${url.search}`);
    }

    return new Response("Not found", { status: 404 });
  },
};

```

{% hint style="warning" %}
Your **Bot ID** is the Discord application ID of your Boost Bot, not your personal Discord ID. You can find it in the [Discord Developer Portal](https://discord.com/developers/applications).
{% endhint %}
{% endstep %}

{% step %}

## Attach a Custom Domain to the Worker

1. Open the Worker you just created.
2. Go to **Settings** → **Domains & Routes** → **Add** → **Custom Domain**.
3. Enter the subdomain you want (e.g. `shop.yourdomain.com`).
4. Click **Add Domain** — Cloudflare will automatically handle the DNS record.

After a few minutes, your domain will be live and routing correctly.
{% endstep %}

{% step %}

## Update Your Bot Config (Optional)

To make your bot display your custom domain in messages (instead of the raw API URL), add the following line to your `Config.yaml`:

```yaml
CustomSiteDomain: "https://shop.yourdomain.com"
```

This makes the bot send customers your branded link for the stock and redeem pages.
{% endstep %}
{% endstepper %}

## Testing

Once everything is set up, open these URLs in your browser:

| URL                                            | Expected Result         |
| ---------------------------------------------- | ----------------------- |
| `https://shop.yourdomain.com/stock`            | Live Stock page loads   |
| `https://shop.yourdomain.com/redeem`           | Redeem form loads       |
| `https://shop.yourdomain.com/orders/<orderId>` | Order detail page loads |

If you see **"Page Offline"**, your bot may not be running. Start the bot and try again.
