From 071dc4ef675236a5d702617d258a56168f47faf2 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 7 Feb 2026 21:28:55 +0100 Subject: [PATCH 1/5] Don't use cache for building Docker images --- .github/workflows/cd.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6a29ad8..54dc859 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,7 +33,3 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/strava-heatmap-proxy:latest ${{ secrets.DOCKERHUB_USERNAME }}/strava-heatmap-proxy:${{ github.sha }} - cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/strava-heatmap-proxy:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/strava-heatmap-proxy:buildcache,mode=max - provenance: false - sbom: false From 5fac42d2b99dc49144f298c65bebc99e9d37222f Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 7 Feb 2026 21:50:19 +0100 Subject: [PATCH 2/5] Don't use CMD in Dockerfile --- Dockerfile | 7 +++---- README.md | 16 ++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7a5358..bb77afd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ # --- Build stage --- FROM golang:1.24 AS build +COPY ./ /src WORKDIR /src -# Build the proxy binary from the module ROOT (no cmd/... suffix) -RUN CGO_ENABLED=0 go install github.com/patrickziegler/strava-heatmap-proxy@latest +RUN CGO_ENABLED=0 go install # --- Runtime stage --- FROM gcr.io/distroless/base-debian13:nonroot @@ -12,6 +12,5 @@ WORKDIR /app COPY --from=build /go/bin/strava-heatmap-proxy ./ EXPOSE 8080 USER nonroot:nonroot -# Looks for cookies at /config/strava-cookies.json by default (mount it read-only) + ENTRYPOINT ["/app/strava-heatmap-proxy"] -CMD ["--port","8080","--cookies","/config/strava-cookies.json"] diff --git a/README.md b/README.md index 566588f..bed819e 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ To do so, you need the following two pieces: 1. The [strava-cookie-exporter](#export-cookies) browser extension to export the necessary cookies as json file 1. The [strava-heatmap-proxy](#run-the-proxy) server which adds the necessary cookies to your requests before redirecting them to Strava -Note: [Previous versions](https://github.com/patrickziegler/strava-heatmap-proxy/tree/v1) of this repository were able to login to Strava automatically when running the proxy server. -Due to recent changes on Strava side this is not possible anymore and we need to extract (at least) a valid session identifier via the browser extension. -The proxy will then automatically refresh CloudFront tokens in case they have expired. +> [!NOTE] +> [Previous versions](https://github.com/patrickziegler/strava-heatmap-proxy/tree/v1) of this repository were able to login to Strava automatically when running the proxy server. +> Due to recent changes on Strava side this is not possible anymore and we need to extract (at least) a valid session identifier via the browser extension. +> The proxy will then automatically refresh CloudFront tokens in case they have expired. ## :hammer_and_wrench: Build and Install @@ -24,16 +25,15 @@ In case you don't have these tools available, the `Dockerfile` allows to build a ```sh docker build -t strava-heatmap-proxy . -docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/config:ro strava-heatmap-proxy +docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/home/nonroot/.config/strava-heatmap-proxy:ro strava-heatmap-proxy ``` Alternatively, you can download and execute a pre-built [container image](https://hub.docker.com/repository/docker/patrickziegler/strava-heatmap-proxy) with the following command: ```sh -docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/config:ro docker.io/patrickziegler/strava-heatmap-proxy:latest +docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/home/nonroot/.config/strava-heatmap-proxy:ro docker.io/patrickziegler/strava-heatmap-proxy:latest ``` - ## :world_map: Usage ### Export cookies @@ -67,7 +67,7 @@ To use this with your GIS software of choice, just define a simple [TMS](https:/ 5 16 - http://localhost:8080/identified/globalheat/all/bluered/%1/%2/%3.png?v=19 + http://localhost:8080/identified/globalheat/all/bluered/{z}/{x}/{y}.png?v=19 ``` @@ -80,7 +80,7 @@ Web clients like [gpx.studio](https://gpx.studio/) need to be whitelisted via th Otherwise the browser would reject the responses due to a violation of the [same-origin policy](https://en.wikipedia.org/wiki/Same-origin_policy). ```sh -strava-heatmap-proxy --allow-origins '["https://gpx.studio"]' --port 8080 +strava-heatmap-proxy --allow-origins '["https://gpx.studio"]' ``` With that in place, you can add the custom layer `http://localhost:8080/identified/globalheat/all/bluered/{z}/{x}/{y}.png?v=19` for accessing the heatmap. From 6d8ee386ab9b75206a2127efa33784f865f5619b Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 7 Feb 2026 23:04:45 +0100 Subject: [PATCH 3/5] Move golang code to subfolder --- .github/workflows/cd.yml | 7 +--- .github/workflows/ci.yml | 13 ++---- .gitignore | 2 +- Makefile | 36 ++-------------- README.md | 8 ++-- go.mod | 3 -- strava-cookie-exporter/Makefile | 14 +++++++ Dockerfile => strava-heatmap-proxy/Dockerfile | 2 +- strava-heatmap-proxy/Makefile | 42 +++++++++++++++++++ .../cmd/strava-heatmap-proxy/main.go | 0 strava-heatmap-proxy/go.mod | 3 ++ go.sum => strava-heatmap-proxy/go.sum | 0 .../systemd/strava-heatmap-proxy.service | 1 - 13 files changed, 75 insertions(+), 56 deletions(-) delete mode 100644 go.mod create mode 100644 strava-cookie-exporter/Makefile rename Dockerfile => strava-heatmap-proxy/Dockerfile (84%) create mode 100644 strava-heatmap-proxy/Makefile rename strava-heatmap-proxy.go => strava-heatmap-proxy/cmd/strava-heatmap-proxy/main.go (100%) create mode 100644 strava-heatmap-proxy/go.mod rename go.sum => strava-heatmap-proxy/go.sum (100%) rename strava-heatmap-proxy.service => strava-heatmap-proxy/systemd/strava-heatmap-proxy.service (99%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 54dc859..4eb61ff 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,10 +5,7 @@ on: branches: [ "main" ] paths: - ".github/workflows/**" - - "Dockerfile" - - "go.mod" - - "go.sum" - - "strava-heatmap-proxy.go" + - "strava-heatmap-proxy/**" jobs: cd: @@ -27,7 +24,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: . + context: strava-heatmap-proxy/ platforms: linux/amd64 push: true tags: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36581a8..cfe7e5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,21 +10,16 @@ jobs: - uses: actions/setup-go@v6 with: - go-version-file: 'go.mod' + go-version-file: "strava-heatmap-proxy/go.mod" - - name: Check gofmt - run: | - UNFORMATTED=$(gofmt -l .) - if [ -n "$UNFORMATTED" ]; then - echo -e "The following files are not properly formatted:\n${UNFORMATTED}" - exit 1 - fi + - name: Check code format + run: make -C strava-heatmap-proxy formatcheck - uses: docker/setup-buildx-action@v3 - name: Build image uses: docker/build-push-action@v6 with: - context: . + context: strava-heatmap-proxy/ platforms: linux/amd64 push: false diff --git a/.gitignore b/.gitignore index fdb260b..6063600 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ build/ TODO strava-cookie-exporter.zip -strava-heatmap-proxy +strava-heatmap-proxy/strava-heatmap-proxy diff --git a/Makefile b/Makefile index 1666973..4336362 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,6 @@ -SERVICE_NAME := strava-heatmap-proxy -EXTENSION_NAME := strava-cookie-exporter +SUBDIRS := strava-cookie-exporter strava-heatmap-proxy -OUTPUT := \ - $(SERVICE_NAME) \ - $(EXTENSION_NAME).zip +.PHONY: $(SUBDIRS) all clean -.PHONY: all clean - -all: $(OUTPUT) - -$(SERVICE_NAME): - go build $@.go - -$(EXTENSION_NAME).zip: - 7z a $@ ./$(EXTENSION_NAME)/* - -clean: - rm -f $(OUTPUT) - -install: - GOPATH=$(HOME)/.local go install $(SERVICE_NAME).go - mkdir -p $(HOME)/.config/systemd/user/ - cp $(SERVICE_NAME).service $(HOME)/.config/systemd/user/ - systemctl --user daemon-reload - systemctl --user start $(SERVICE_NAME) - systemctl --user enable $(SERVICE_NAME) - -uninstall: - rm -f $(addprefix $(HOME)/.local/bin/, $(SERVICE_NAME)) - rm $(HOME)/.config/systemd/user/$(SERVICE_NAME).service - systemctl --user disable $(SERVICE_NAME) - systemctl --user stop $(SERVICE_NAME) - systemctl --user daemon-reload +all clean: + $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@;) diff --git a/README.md b/README.md index bed819e..9061eeb 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ To do so, you need the following two pieces: ## :hammer_and_wrench: Build and Install -With [git](https://git-scm.com/downloads), [golang](https://go.dev/) and [make](https://www.gnu.org/software/make/) available on your system, the following steps are sufficient to build and install `strava-heatmap-proxy` to the given path `INSTALL_PREFIX`: +With [git](https://git-scm.com/downloads), [golang](https://go.dev/) available on your system, the following steps are sufficient to build and install `strava-heatmap-proxy`: ```sh -git clone https://github.com/patrickziegler/strava-heatmap-proxy -cd strava-heatmap-proxy -INSTALL_PREFIX=~/.local/bin make install +git clone https://github.com/patrickziegler/strava-heatmap-proxy && cd $_ +cd ./strava-heatmap-proxy +GOPATH=$HOME/.local go install ./cmd/strava-heatmap-proxy ``` In case you don't have these tools available, the `Dockerfile` allows to build a containerized version of the proxy server as well: diff --git a/go.mod b/go.mod deleted file mode 100644 index e087c20..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/patrickziegler/strava-heatmap-proxy - -go 1.24 diff --git a/strava-cookie-exporter/Makefile b/strava-cookie-exporter/Makefile new file mode 100644 index 0000000..9b1fc70 --- /dev/null +++ b/strava-cookie-exporter/Makefile @@ -0,0 +1,14 @@ +EXTENSION_NAME := strava-cookie-exporter + +OUTPUT := \ + $(EXTENSION_NAME).zip + +.PHONY: all clean + +all: $(OUTPUT) + +$(EXTENSION_NAME).zip: + 7z a $@ ./* -x!Makefile + +clean: + rm -f $(OUTPUT) diff --git a/Dockerfile b/strava-heatmap-proxy/Dockerfile similarity index 84% rename from Dockerfile rename to strava-heatmap-proxy/Dockerfile index bb77afd..ead1d3b 100644 --- a/Dockerfile +++ b/strava-heatmap-proxy/Dockerfile @@ -4,7 +4,7 @@ FROM golang:1.24 AS build COPY ./ /src WORKDIR /src -RUN CGO_ENABLED=0 go install +RUN CGO_ENABLED=0 go install ./cmd/strava-heatmap-proxy # --- Runtime stage --- FROM gcr.io/distroless/base-debian13:nonroot diff --git a/strava-heatmap-proxy/Makefile b/strava-heatmap-proxy/Makefile new file mode 100644 index 0000000..b64f553 --- /dev/null +++ b/strava-heatmap-proxy/Makefile @@ -0,0 +1,42 @@ +SERVICE_NAME := strava-heatmap-proxy +LOCAL_PORT := 9192 + +OUTPUT := \ + $(SERVICE_NAME) + +.PHONY: all clean install uninstall formatcheck container + +all: $(OUTPUT) + +$(SERVICE_NAME): + go build ./cmd/$@ + +clean: + rm -f $(OUTPUT) + +install: + GOPATH=$(HOME)/.local go install ./cmd/$(SERVICE_NAME) + mkdir -p $(HOME)/.config/systemd/user/ + cp ./systemd/$(SERVICE_NAME).service $(HOME)/.config/systemd/user/ + systemctl --user daemon-reload + systemctl --user restart $(SERVICE_NAME) + systemctl --user enable $(SERVICE_NAME) + +uninstall: + rm -f $(addprefix $(HOME)/.local/bin/, $(SERVICE_NAME)) + rm -f $(HOME)/.config/systemd/user/$(SERVICE_NAME).service + systemctl --user disable $(SERVICE_NAME) || true + systemctl --user stop $(SERVICE_NAME) || true + systemctl --user daemon-reload + +formatcheck: + UNFORMATTED=$$(gofmt -l .) && \ + if [ -n "$$UNFORMATTED" ]; then \ + echo "The following files are not properly formatted:"; \ + echo "$$UNFORMATTED"; \ + exit 1; \ + fi + +container: + docker build -t $(SERVICE_NAME) . + docker run --rm -p $(LOCAL_PORT):8080 -v $(HOME)/.config/$(SERVICE_NAME):/home/nonroot/.config/$(SERVICE_NAME):ro $(SERVICE_NAME) || true diff --git a/strava-heatmap-proxy.go b/strava-heatmap-proxy/cmd/strava-heatmap-proxy/main.go similarity index 100% rename from strava-heatmap-proxy.go rename to strava-heatmap-proxy/cmd/strava-heatmap-proxy/main.go diff --git a/strava-heatmap-proxy/go.mod b/strava-heatmap-proxy/go.mod new file mode 100644 index 0000000..b26de23 --- /dev/null +++ b/strava-heatmap-proxy/go.mod @@ -0,0 +1,3 @@ +module github.com/patrickziegler/strava-heatmap-proxy/strava-heatmap-proxy + +go 1.24 diff --git a/go.sum b/strava-heatmap-proxy/go.sum similarity index 100% rename from go.sum rename to strava-heatmap-proxy/go.sum diff --git a/strava-heatmap-proxy.service b/strava-heatmap-proxy/systemd/strava-heatmap-proxy.service similarity index 99% rename from strava-heatmap-proxy.service rename to strava-heatmap-proxy/systemd/strava-heatmap-proxy.service index 5d825a1..3688f04 100644 --- a/strava-heatmap-proxy.service +++ b/strava-heatmap-proxy/systemd/strava-heatmap-proxy.service @@ -9,6 +9,5 @@ ExecStart=%h/.local/bin/strava-heatmap-proxy --port ${STRAVA_HEATMAP_PROXY_PORT} Restart=on-failure RestartSec=5 - [Install] WantedBy=default.target From fa5215a5e6b22299aaea7b515a537d964dee811b Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 7 Feb 2026 23:22:21 +0100 Subject: [PATCH 4/5] Rename github workflows --- .github/workflows/{ci.yml => build-and-test.yml} | 2 +- .github/workflows/{cd.yml => deploy.yml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{ci.yml => build-and-test.yml} (94%) rename .github/workflows/{cd.yml => deploy.yml} (96%) diff --git a/.github/workflows/ci.yml b/.github/workflows/build-and-test.yml similarity index 94% rename from .github/workflows/ci.yml rename to .github/workflows/build-and-test.yml index cfe7e5a..166c9ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -name: strava-heatmap-proxy-ci +name: build-and-test on: [ "pull_request" ] diff --git a/.github/workflows/cd.yml b/.github/workflows/deploy.yml similarity index 96% rename from .github/workflows/cd.yml rename to .github/workflows/deploy.yml index 4eb61ff..bef0532 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: strava-heatmap-proxy-cd +name: deploy on: push: From 05b3f6ce719416705eff82665f64f4a51dd19736 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 7 Feb 2026 23:57:08 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 54 ++++++++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 9061eeb..6f35147 100644 --- a/README.md +++ b/README.md @@ -11,30 +11,7 @@ To do so, you need the following two pieces: > Due to recent changes on Strava side this is not possible anymore and we need to extract (at least) a valid session identifier via the browser extension. > The proxy will then automatically refresh CloudFront tokens in case they have expired. -## :hammer_and_wrench: Build and Install - -With [git](https://git-scm.com/downloads), [golang](https://go.dev/) available on your system, the following steps are sufficient to build and install `strava-heatmap-proxy`: - -```sh -git clone https://github.com/patrickziegler/strava-heatmap-proxy && cd $_ -cd ./strava-heatmap-proxy -GOPATH=$HOME/.local go install ./cmd/strava-heatmap-proxy -``` - -In case you don't have these tools available, the `Dockerfile` allows to build a containerized version of the proxy server as well: - -```sh -docker build -t strava-heatmap-proxy . -docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/home/nonroot/.config/strava-heatmap-proxy:ro strava-heatmap-proxy -``` - -Alternatively, you can download and execute a pre-built [container image](https://hub.docker.com/repository/docker/patrickziegler/strava-heatmap-proxy) with the following command: - -```sh -docker run --rm -p 8080:8080 -v ~/.config/strava-heatmap-proxy:/home/nonroot/.config/strava-heatmap-proxy:ro docker.io/patrickziegler/strava-heatmap-proxy:latest -``` - -## :world_map: Usage +## Usage ### Export cookies @@ -46,16 +23,21 @@ With this extension installed, you can: The exported file is needed for running [strava-heatmap-proxy](#run-the-proxy). +Even though the exported cookies have an expiration period of 24 hours, you'll like only need to export them once because the proxy can automatically refresh expired cookies as long as the session is valid (the exact duration of that is unkown right now, but it seems to be several months at least). + ### Run the proxy -Running the tool `strava-heatmap-proxy` from your terminal will set up a local proxy server for `https://content-a.strava.com/`. -Every request to `http://localhost:8080/` will then be extended with session cookies before being forwarded to Strava. -You can configure different target URLs or port numbers via the `--target` or `--port` options. +You can use the [prebuilt Docker image](https://hub.docker.com/repository/docker/patrickziegler/strava-heatmap-proxy) for running a local instance of the proxy server in your terminal: -By default, the necessary cookies are expected to be found in the file `${HOME}/.config/strava-heatmap-proxy/strava-cookies.json` (should be manually created with the `strava-cookie-exporter` extension). -You can configure different locations of that file via the `--cookies` option. +```sh +LOCAL_PORT=8080 +docker run --rm -p ${LOCAL_PORT}:8080 -v ${HOME}/.config/strava-heatmap-proxy:/home/nonroot/.config/strava-heatmap-proxy:ro docker.io/patrickziegler/strava-heatmap-proxy:latest +``` -The CloudFront cookies have an expiration period of 24 hours, but you don't need to recreate the `strava-cookies.json` file all the time because `strava-heatmap-proxy` can automatically refresh expired cookies as long as the session is valid (the exact duration of that is unkown right now, but it seems to be several weeks at least). +This will set up a local proxy server for `https://content-a.strava.com/`. +Every request to `http://localhost:8080/` will then be extended with session cookies before being forwarded to Strava. + +By default, the necessary cookies are expected to be found in the file `${HOME}/.config/strava-heatmap-proxy/strava-cookies.json` (as created with the [strava-cookie-exporter](#export-cookies) extension). ### Configure your TMS client @@ -76,20 +58,16 @@ The `ServerUrl` can hold other elements than `all` and `bluered`. If you want to ### Advanced configuration for web clients -Web clients like [gpx.studio](https://gpx.studio/) need to be whitelisted via the `--allow-origins` option. +Web clients like [gpx.studio](https://gpx.studio/) need to be whitelisted via the `--allow-origins '["https://gpx.studio"]'` option. Otherwise the browser would reject the responses due to a violation of the [same-origin policy](https://en.wikipedia.org/wiki/Same-origin_policy). -```sh -strava-heatmap-proxy --allow-origins '["https://gpx.studio"]' -``` - -With that in place, you can add the custom layer `http://localhost:8080/identified/globalheat/all/bluered/{z}/{x}/{y}.png?v=19` for accessing the heatmap. +With the option in place, you can add the custom layer `http://localhost:8080/identified/globalheat/all/bluered/{z}/{x}/{y}.png?v=19` for accessing the heatmap. ## Screenshot -And this is how the result might look like in [QMapShack](https://github.com/Maproom/qmapshack/wiki): +This is how the result might look like in [QMapShack](https://github.com/Maproom/qmapshack/wiki): -![screenshot of tms client](https://addons.mozilla.org/user-media/previews/full/327/327795.png) +![screenshot of tms client](https://addons.mozilla.org/user-media/previews/full/351/351337.png) ## References