Skip to content

faeton/steamcommunitx.com

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Steam to Dotabuff Redirector

Overview

This Cloudflare Worker-based service allows users to convert Steam Vanity URLs and SteamID-based profile URLs into Dotabuff player profile links. It automatically handles Steam Vanity URLs by resolving them through the Steam API and processes SteamID64 and Steam3 formats locally without API calls.

Features

  • Supports Steam Vanity URLs (e.g., steamcommunity.com/id/gabelogannewell → API resolution required)
  • Handles SteamID-based URLs locally (e.g., steamcommunity.com/profiles/76561197960287930 → converted without API)
  • Automatic Redirects to Dotabuff player profiles
  • Google Analytics Integration (ensuring tracking before redirection)
  • Cloudflare Workers Optimization
  • Secure API Key Handling using Cloudflare Worker Secrets

How It Works

  1. Vanity URLs: If a user enters a Steam Vanity URL (/id/{username}), the service queries the Steam API to resolve the corresponding SteamID64.
  2. SteamID64 URLs: If a user enters a /profiles/{SteamID64}, the system locally converts it to a Dota 2 Player ID.
  3. Steam3 IDs: If the URL contains a Steam3 ID format (e.g., [U:1:22202]), it is converted directly without API usage.
  4. Google Analytics: The redirect page ensures Google Analytics tracking before sending the user to Dotabuff.

URL Usage

  • Vanity Name URL: https://steamcommunitx.com/id/{username} (Requires API resolution)
  • SteamID64 URL: https://steamcommunitx.com/profiles/{steamID64} (Converted locally)
  • Steam3 ID URL: https://steamcommunitx.com/profiles/[U:1:{dotaID}] (Converted locally)

All formats redirect to Dotabuff:

https://www.dotabuff.com/players/{dotaID}

Setup & Deployment

1. Deploy to Cloudflare Workers

  • Clone the repository and navigate to the project folder.
  • Deploy the worker using Cloudflare’s dashboard or Wrangler CLI.

2. Set Up Secrets and Variables

Go to Cloudflare Dashboard → Workers & Pages → Select Your Worker → SettingsVariables and Secrets.

Required:

Optional:

  • STEAM_API_KEYS (secret) — comma-separated list of additional Steam API keys for rotation under load. Whitespace around commas is trimmed automatically.
  • GA_ID (var) — Google Analytics 4 measurement ID (e.g. G-XXXXXXX). Injected into the <head> of every HTML page. Omit to disable GA.
  • MATOMO_URL and MATOMO_SITE_ID (var) — Matomo tracker base URL (must end with /, e.g. //m.example.com/) and numeric site ID. Both are required together; either alone is ignored. Omit to disable Matomo.

Analytics values are validated against strict format guards before being inlined into HTML, so a malformed value is silently dropped rather than producing broken markup.

3. KV Namespace Bindings (Optional)

The worker uses two KV namespaces. Both are optional — the worker degrades gracefully if a binding is missing, but you lose caching / health tracking.

Create namespaces in Workers & Pages → KV, then bind them to the worker under Settings → Variables and Secrets → KV Namespace Bindings:

Variable name Purpose
STEAM_ID_CACHE Caches resolved vanity → steamID64 for 30 days.
API_KEY_STATUS Marks invalid / rate-limited API keys so the next request skips them.

Note: a previous version of the worker used a RATE_LIMITS KV binding for in-worker rate limiting. That has been removed — KV is not suitable for atomic counters. If you need rate limiting, configure it via Cloudflare WAF Rate Limiting Rules or the native Workers Rate Limiting binding.

4. Bind Custom Domain (Optional)

To use a custom domain like steamcommunitx.com, configure Cloudflare DNS settings and map the domain to the worker.

Code Breakdown

Key Files:

  • worker.js: The main Cloudflare Worker script that handles requests, processes Steam IDs, and redirects.
  • README.md: This doc.

The original 2017 PHP prototype is preserved on the legacy-php-2017 branch for historical reference.

Optimized Redirect Logic

  • Uses window.onload to ensure all tracking scripts load before redirecting.
  • Redirects both SteamID-based URLs and Vanity URLs to Dotabuff.
  • Implements proper error handling for missing API keys and invalid Steam IDs.

Contributing

Feel free to submit pull requests for improvements, bug fixes, or additional features.

License

MIT License.

About

Cloudflare Worker that redirects Steam profile URLs (vanity, SteamID64, SteamID3) to the matching Dotabuff player profile

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors