Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml → .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: strava-heatmap-proxy-ci
name: build-and-test

on: [ "pull_request" ]

Expand All @@ -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
13 changes: 3 additions & 10 deletions .github/workflows/cd.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: strava-heatmap-proxy-cd
name: deploy

on:
push:
branches: [ "main" ]
paths:
- ".github/workflows/**"
- "Dockerfile"
- "go.mod"
- "go.sum"
- "strava-heatmap-proxy.go"
- "strava-heatmap-proxy/**"

jobs:
cd:
Expand All @@ -27,13 +24,9 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
context: strava-heatmap-proxy/
platforms: linux/amd64
push: true
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ build/

TODO
strava-cookie-exporter.zip
strava-heatmap-proxy
strava-heatmap-proxy/strava-heatmap-proxy
36 changes: 4 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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) $@;)
64 changes: 21 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,12 @@ 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

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`:

```sh
git clone https://github.com/patrickziegler/strava-heatmap-proxy
cd strava-heatmap-proxy
INSTALL_PREFIX=~/.local/bin make install
```

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:/config: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
```


## :world_map: Usage
## Usage

### Export cookies

Expand All @@ -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

Expand All @@ -67,7 +49,7 @@ To use this with your GIS software of choice, just define a simple [TMS](https:/
<MinZoomLevel>5</MinZoomLevel>
<MaxZoomLevel>16</MaxZoomLevel>
<Layer idx="0">
<ServerUrl>http://localhost:8080/identified/globalheat/all/bluered/%1/%2/%3.png?v=19</ServerUrl>
<ServerUrl>http://localhost:8080/identified/globalheat/all/bluered/{z}/{x}/{y}.png?v=19</ServerUrl>
</Layer>
</TMS>
```
Expand All @@ -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"]' --port 8080
```

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

Expand Down
3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

14 changes: 14 additions & 0 deletions strava-cookie-exporter/Makefile
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 3 additions & 4 deletions Dockerfile → strava-heatmap-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

# --- 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 ./cmd/strava-heatmap-proxy

# --- Runtime stage ---
FROM gcr.io/distroless/base-debian13:nonroot
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"]
42 changes: 42 additions & 0 deletions strava-heatmap-proxy/Makefile
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
3 changes: 3 additions & 0 deletions strava-heatmap-proxy/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/patrickziegler/strava-heatmap-proxy/strava-heatmap-proxy

go 1.24
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading