A simple and intelligent redirector for your Polarsteps trips. This service allows you to use a custom domain to automatically redirect to your latest Polarsteps trip.
The service works by mapping a domain name to a Polarsteps username. When a request is received, it does the following:
- Finds your username: It looks up the Polarsteps username associated with the domain name in the
domains.yamlfile. - Fetches your trips: It uses the Polarsteps API to get a list of all your trips.
- Selects the best trip: It intelligently selects which trip to redirect to based on the following priority:
- An ongoing trip.
- The next upcoming trip (closest to the current date).
- The most recently completed trip.
- Redirects: It redirects the user to the selected trip's URL. If no suitable trip is found, it redirects to your main Polarsteps profile page.
This project is designed to be run with Docker.
- Docker installed on your machine.
-
Edit
domains.yamlfile: Editdomains.yamlfile in the root of the project with the following format:domains: your-domain.com: your-polarsteps-username another-domain.com: another-polarsteps-username
The service will automatically handle www. subdomains. For example, if you configure example.com, www.example.com will also be redirected.
-
Build and run the Docker container:
docker build -t trips-redirect . docker run -d -p 3000:3000 -v $(pwd)/domains.yaml:/domains.yaml --name trips-redirect trips-redirect
This will start the service on port 3000.
The following environment variables can be configured:
PORT- The port to run the service on (default: 3000)
The service supports Rybbit Analytics for tracking redirections and errors. To enable analytics, set the following environment variables:
RYBBIT_API_KEY- Your Rybbit API keyRYBBIT_API_URL- The Rybbit API endpoint URLRYBBIT_SITE_ID- Your Rybbit site ID
All three variables must be set to enable analytics. If any variable is missing, analytics will be disabled.
Example with analytics enabled:
docker run -d -p 3000:3000 \
-v $(pwd)/domains.yaml:/domains.yaml \
-e RYBBIT_API_KEY=your-api-key \
-e RYBBIT_API_URL=https://api.rybbit.io/events \
-e RYBBIT_SITE_ID=your-site-id \
--name trips-redirect trips-redirectThe service tracks the following events:
- Pageview: Successful redirections and profile fallbacks
- Outbound: Redirects to Polarsteps trip pages
- Error: 404 errors and API failures
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
Here are some ways you can contribute:
- Improve the documentation.
- Add new features.
- Fix bugs.
- Suggest new ideas.
docker manifest inspect ghcr.io/thomasorgeval/trips-redirect --verbose | jq '.[0].OCIManifest.layers[].size' | awk '{sum += $1} END {print "Total compressed size: " sum " bytes (" sum/1024/1024 " MB)"}'