This document explains the technical implementation of the proxy system in TMDB Addon.
addon/utils/httpClient.js- Custom HTTP client with proxy supportaddon/utils/tmdbClient.js- MovieDb wrapper with proxy integration- Environment variable configuration - Flexible proxy control
Request → httpClient.js → Check domain → Proxy (if TMDB) → Response
// Configuration based on environment variables
const PROXY_CONFIG = {
enabled: process.env.TMDB_PROXY_ENABLED === 'true',
host: process.env.TMDB_PROXY_HOST || '127.0.0.1',
port: process.env.TMDB_PROXY_PORT || 1080,
protocol: process.env.TMDB_PROXY_PROTOCOL || 'http'
};
// Domain verification
function shouldUseProxy(url) {
const TMDB_DOMAINS = ['api.themoviedb.org', 'image.tmdb.org', 'www.themoviedb.org'];
const urlObj = new URL(url);
return TMDB_DOMAINS.some(domain => urlObj.hostname.includes(domain));
}class TMDBClient extends MovieDb {
constructor(apiKey) {
super(apiKey);
// Replace default request method
this._request = async (url, options = {}) => {
const instance = createAxiosInstance(url);
return instance.request({ url, ...options });
};
}
}All modules that make requests to TMDB have been updated to use TMDBClient:
getTmdb.jsgetMeta.jsgetSearch.jsgetCatalog.jsgetTrending.jsgetPersonalLists.jsgetLogo.jsgetLanguages.jsgetGenreList.jsgetEpisodes.jsgetSession.js
| Variable | Default | Description |
|---|---|---|
TMDB_PROXY_ENABLED |
false |
Enable/disable proxy |
TMDB_PROXY_HOST |
127.0.0.1 |
Proxy host |
TMDB_PROXY_PORT |
1080 |
Proxy port |
TMDB_PROXY_PROTOCOL |
http |
Protocol (http, https, socks4, socks5) |
TMDB_PROXY_AUTH |
false |
Enable authentication |
TMDB_PROXY_USERNAME |
- | Proxy username |
TMDB_PROXY_PASSWORD |
- | Proxy password |
TMDB_PROXY_ENABLED=true
TMDB_PROXY_HOST=proxy.example.com
TMDB_PROXY_PORT=8080
TMDB_PROXY_PROTOCOL=httpTMDB_PROXY_ENABLED=true
TMDB_PROXY_HOST=127.0.0.1
TMDB_PROXY_PORT=40000
TMDB_PROXY_PROTOCOL=socks5TMDB_PROXY_ENABLED=true
TMDB_PROXY_HOST=proxy.example.com
TMDB_PROXY_PORT=8080
TMDB_PROXY_PROTOCOL=http
TMDB_PROXY_AUTH=true
TMDB_PROXY_USERNAME=user
TMDB_PROXY_PASSWORD=passGET /api/proxy/status
Response:
{
"enabled": true,
"host": "127.0.0.1",
"port": 40000,
"protocol": "socks5",
"working": true
}The system automatically logs when using proxy:
Usando proxy para: https://api.themoviedb.org/3/configuration
# Test configuration
npm run test:proxy
# Test endpoint
curl http://localhost:1337/api/proxy/status- Isolation: Only TMDB requests use proxy
- Credentials: Stored only in environment variables
- Logs: Do not log sensitive credentials
- Timeout: Configured timeout to prevent hanging
- Use trusted proxies (Cloudflare WARP, etc.)
- Monitor logs for issues
- Test connectivity regularly
- Use HTTPS when possible
- Cache: Addon maintains cache to reduce requests
- Timeout: Configured timeout to prevent hanging
- Selective: Only TMDB uses proxy, other requests are direct
- Use
/api/proxy/statusto verify operation - Monitor logs for latency
- Configure appropriate timeouts
-
Proxy not connecting
- Check if proxy is running
- Test with
curl --proxy - Verify configurations
-
Timeout
- Increase timeout in configurations
- Use closer proxy
- Check bandwidth
-
Authentication error
- Verify credentials
- Ensure
TMDB_PROXY_AUTH=true - Test authentication independently
# Test proxy independently
curl --proxy socks5://127.0.0.1:40000 https://api.themoviedb.org/3/configuration
# Check addon logs
docker logs tmdb-addon
# Test configuration
npm run test:proxyTo add new domains that should use proxy:
// In httpClient.js
const TMDB_DOMAINS = [
'api.themoviedb.org',
'image.tmdb.org',
'www.themoviedb.org',
'new-domain.com' // Add here
];The system uses axios, which automatically supports HTTP, HTTPS, SOCKS4 and SOCKS5.