# LunaTV Douban Proxy Options: Complete Configuration Guide

> Discover LunaTV's six Douban proxy options direct cors-proxy-zwei cmliussss-cdn-tencent cmliussss-cdn-ali cors-anywhere and custom. Configure them easily via localStorage or environment variables.

- Repository: [MoonTechLab/LunaTV](https://github.com/MoonTechLab/LunaTV)
- Tags: how-to-guide
- Published: 2026-09-09

---

**LunaTV provides six distinct Douban proxy options—`direct`, `cors-proxy-zwei`, `cmliussss-cdn-tencent`, `cmliussss-cdn-ali`, `cors-anywhere`, and `custom`—that developers configure through `localStorage` or runtime environment variables in [`src/lib/douban.client.ts`](https://github.com/MoonTechLab/LunaTV/blob/main/src/lib/douban.client.ts).**

LunaTV is an open-source media interface that integrates Douban metadata through a flexible proxy abstraction layer. Understanding the available **Douban proxy options in LunaTV** allows developers to optimize request routing for different network conditions and geographic regions. The configuration logic is centralized in the `getDoubanProxyConfig()` function, which evaluates browser storage and runtime constants to determine request routing.

## How Proxy Configuration Works in LunaTV

The `getDoubanProxyConfig()` function in `[src/lib/douban.client.ts]` serves as the configuration gateway for all Douban data requests. It checks two primary sources: `localStorage.getItem('doubanDataSource')` for the proxy type and `localStorage.getItem('doubanProxyUrl')` for custom endpoints. If localStorage values are absent, the function falls back to `(window as any).RUNTIME_CONFIG` properties `DOUBAN_PROXY_TYPE` and `DOUBAN_PROXY`.

```typescript
// src/lib/douban.client.ts
function getDoubanProxyConfig(): {
  proxyType: 'direct' | 'cors-proxy-zwei' | 'cmliussss-cdn-tencent' | 'cmliussss-cdn-ali' | 'cors-anywhere' | 'custom';
  proxyUrl: string;
} {
  const doubanProxyType =
    localStorage.getItem('doubanDataSource') ||
    (window as any).RUNTIME_CONFIG?.DOUBAN_PROXY_TYPE ||
    'cmliussss-cdn-tencent';
  const doubanProxy =
    localStorage.getItem('doubanProxyUrl') ||
    (window as any).RUNTIME_CONFIG?.DOUBAN_PROXY ||
    '';
  return { proxyType: doubanProxyType, proxyUrl: doubanProxy };
}

```

The returned configuration object drives subsequent data fetching in `getDoubanCategories()`, `getDoubanList()`, and `getDoubanRecommends()`.

## Available Douban Proxy Types

LunaTV supports six proxy strategies, each optimized for specific network scenarios and deployment requirements.

### Direct Connection (`direct`)

Setting the proxy type to **`direct`** disables intermediary routing, sending requests straight to the official Douban API. Use this option when operating in environments with unrestricted access to Douban servers and no CORS restrictions.

### CORS Proxy Services

For browsers facing cross-origin restrictions, LunaTV integrates two public CORS proxy options:

- **`cors-proxy-zwei`**: Routes traffic through `https://ciao-cors.is-an.org/`
- **`cors-anywhere`**: Utilizes the generic service at `https://cors-anywhere.com/`

These options wrap Douban API requests to bypass browser same-origin policy limitations during client-side fetching.

### CDN Routes (`cmliussss-cdn-tencent` and `cmliussss-cdn-ali`)

LunaTV provides optimized request paths through Tencent and Alibaba Cloud CDNs for improved latency in mainland China:

- **`cmliussss-cdn-tencent`**: `https://m.douban.cmliussss.net/`
- **`cmliussss-cdn-ali`**: `https://m.douban.cmliussss.com/`

The Tencent CDN serves as the default fallback when no configuration exists, ensuring out-of-the-box functionality for users in network-restricted regions.

### Custom Proxy Endpoint (`custom`)

The **`custom`** type allows integration of private proxy infrastructure or self-hosted CORS alternatives. When selected, LunaTV reads the endpoint URL from `localStorage.getItem('doubanProxyUrl')` or `RUNTIME_CONFIG.DOUBAN_PROXY`, enabling enterprise deployments with specific security or compliance requirements.

## Configuring Proxy Settings via localStorage

Modify client-side storage to activate different proxy modes without rebuilding the application.

### Switching to Tencent CDN

```javascript
localStorage.setItem('doubanDataSource', 'cmliussss-cdn-tencent');
localStorage.removeItem('doubanProxyUrl');

```

No additional URL is required; the CDN endpoint is hard-coded in the client logic.

### Enabling Custom Proxy

```javascript
localStorage.setItem('doubanDataSource', 'custom');
localStorage.setItem('doubanProxyUrl', 'https://my-proxy.example.com/');

```

### Reverting to Direct Access

```javascript
localStorage.setItem('doubanDataSource', 'direct');
localStorage.removeItem('doubanProxyUrl');

```

## Source Code Architecture

Beyond `[src/lib/douban.client.ts]`, the proxy system involves several critical components that handle the actual data fetching:

- **[src/lib/douban.ts]**: Implements `fetchDoubanData<T>()`, the low-level HTTP client used by server-side API routes when processing requests.
- **[src/app/api/douban/route.ts]**, **[src/app/api/douban/categories/route.ts]**, **[src/app/api/douban/recommends/route.ts]**: Internal Next.js API endpoints that proxy requests to Douban when the client-side configuration demands server-side fetching logic.

This architecture ensures that sensitive proxy credentials or API tokens configured in `custom` mode remain server-side, while public CDN modes execute directly from the client for optimal performance.

## Summary

- LunaTV offers **six proxy types**: `direct`, `cors-proxy-zwei`, `cmliussss-cdn-tencent`, `cmliussss-cdn-ali`, `cors-anywhere`, and `custom`.
- Configuration persists in **`localStorage`** under keys `doubanDataSource` (type) and `doubanProxyUrl` (custom endpoints), with runtime config fallbacks for production deployments.
- The **`cmliussss-cdn-tencent`** option serves as the default fallback for optimal mainland China connectivity.
- **`getDoubanProxyConfig()`** in [`src/lib/douban.client.ts`](https://github.com/MoonTechLab/LunaTV/blob/main/src/lib/douban.client.ts) centralizes all proxy resolution logic.
- Server-side API routes in `src/app/api/douban/` handle `direct` mode requests to protect API integrity and bypass CORS limitations.

## Frequently Asked Questions

### How do I check which Douban proxy is currently active in LunaTV?

Inspect `localStorage.getItem('doubanDataSource')` in your browser console. If this returns `null`, LunaTV defaults to `cmliussss-cdn-tencent` as defined in the fallback chain within `getDoubanProxyConfig()`.

### What is the difference between the Tencent and Alibaba CDN options?

Both `cmliussss-cdn-tencent` and `cmliussss-cdn-ali` route requests through domestic Chinese CDNs, but utilize different infrastructure providers. Tencent (`https://m.douban.cmliussss.net/`) and Alibaba (`https://m.douban.cmliussss.com/`) may exhibit varying latency and reliability depending on your specific ISP and geographic location within China.

### Can I use LunaTV without any proxy?

Yes. Set `localStorage.setItem('doubanDataSource', 'direct')` to enable **direct** mode. This connects straight to Douban's official API, though this may trigger CORS errors in browser environments or connectivity issues in regions with network restrictions.

### Where should I configure the proxy for production deployments?

For production builds, set `RUNTIME_CONFIG.DOUBAN_PROXY_TYPE` and `RUNTIME_CONFIG.DOUBAN_PROXY` environment variables. These runtime constants take precedence over localStorage and ensure consistent configuration across user sessions without requiring JavaScript execution in the browser.