/secondary-domain-redirect

a cloudflare worker that redirects all incoming requests to runpod.io with utm parameters.

Primary LanguageTypeScript

secondary domain redirect

a cloudflare worker that redirects all incoming requests to runpod.io with utm parameters. this worker is designed to handle traffic from secondary domains and redirect visitors to the main runpod website while preserving tracking information.

prerequisites

  • node.js (v16 or higher recommended)
  • pnpm

setup

  1. clone the repository:
git clone https://github.com/runpod/secondary-domain-redirect
cd secondary-domain-redirect
  1. install dependencies:
pnpm install

development

start the development server:

wrangler dev

deployment

deploy to cloudflare workers:

wrangler deploy

how it works

when a visitor accesses any url on the secondary domain, the worker:

  1. captures the current domain from the request
  2. constructs a redirect url to runpod.io
  3. adds utm_source=secondary_domain and utm_campaign=[current domain] as query parameters
  4. returns a 301 redirect response

this allows for proper attribution of traffic coming from secondary domains in analytics tools.