[Bug]: Login redirects back to login page and white screen after admin login (Docker Swarm + Traefik setup)
What happened?
Hello!
After a long time adjusting my stack to run Affine with Traefik, I finally managed to start my stack successfully — there are no errors in the logs. However, I believe there is still a routing issue somewhere in my setup.
Even though I can access the URL and log in with my already created account (I successfully went through the setup process and created an account), when I try to access https://affine.mydomain.com.br (fictional domain), I get redirected back to the login page right after logging in.
Additionally, if I log out and log back in as admin, the login works, but the page remains completely blank — which makes me suspect that I’m being logged out immediately after login.
I didn’t make any special configuration during the Affine setup, so I believe the problem lies in my stack configuration.
It’s worth mentioning that I’m using Docker Compose with Traefik, and the stack is deployed via Docker Swarm + Portainer. I’m not sure if this could affect the behavior.
I’ve already tried setting the SERVER_URL to different values:
https://affine.mydomain.com.br
http://localhost
and also with ports 443, 80, and 3010 as well as setting the SERVER_PORT, but none of these made a difference.
Below I’m including my docker-compose.yml (with my real domain replaced by mydomain) and the .env file, both sanitized for security reasons.
Environment:
Docker Swarm + Portainer + Traefik
Affine (latest stable image)
Redis + Postgres services running as dependencies
My Stack:
services: affine: image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} depends_on: - redis - postgres - affine_migration volumes: - ${UPLOAD_LOCATION}:/root/.affine/storage - ${CONFIG_LOCATION}:/root/.affine/config environment: - REDIS_SERVER_HOST=redis - DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine} - AFFINE_INDEXER_ENABLED=false - AFFINE_SERVER_HTTPS=true - AFFINE_SERVER_HOST=http://affine.mydomain.com.br - AFFINE_SERVER_PORT=3010 networks: - network_public deploy: mode: replicated replicas: 1 placement: constraints: - node.role == manager labels: - "traefik.enable=true" - "traefik.docker.network=network_public" - "traefik.http.routers.affine_app.rule=Host(affine.mydomain.com.br`)"
- "traefik.http.routers.affine_app.entrypoints=websecure"
- "traefik.http.routers.affine_app.tls.certresolver=letsencryptresolver"
- "traefik.http.routers.affine_app.priority=1"
- "traefik.http.routers.affine_app.service=affine_app"
- "traefik.http.services.affine_app.loadbalancer.server.port=3010"
- "traefik.http.services.affine_app.loadbalancer.passhostheader=true"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.affine_app.middlewares=sslheader@docker"
affine_migration: image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} volumes: - ${UPLOAD_LOCATION}:/root/.affine/storage - ${CONFIG_LOCATION}:/root/.affine/config command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js'] networks: - network_public environment: - REDIS_SERVER_HOST=redis - DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine} - AFFINE_INDEXER_ENABLED=false depends_on: - postgres - redis deploy: mode: replicated replicas: 1 placement: constraints: - node.role == manager
redis: image: redis networks: - network_public healthcheck: test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping'] interval: 10s timeout: 5s retries: 5 deploy: mode: replicated replicas: 1 placement: constraints: - node.role == manager
postgres:
image: pgvector/pgvector:pg16
volumes:
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE:-affine}
POSTGRES_INITDB_ARGS: '--data-checksums'
networks:
- network_public
healthcheck:
test: ['CMD', 'pg_isready', '-U', "${DB_USERNAME}", '-d', "${DB_DATABASE:-affine}"]
interval: 10s
timeout: 5s
retries: 5
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
volumes: pgdata: storage: config:
networks: network_public: external: true name: network_public`
My .env:
AFFINE_REVISION=stable PORT=3010 DB_DATA_LOCATION=pgdata UPLOAD_LOCATION=storage CONFIG_LOCATION=config DB_USERNAME=affine DB_PASSWORD=affine DB_DATABASE=affine AFFINE_SERVER_HTTPS=true AFFINE_SERVER_HOST=affine.mydomain.com.br [email protected] AFFINE_ADMIN_PASSWORD=affine AFFINE_SERVER_PORT=3010
Additionally, I’ve attached a video demonstration of the issue and the corresponding logs recorded during the session.
https://github.com/user-attachments/assets/a11c0a09-0e03-4b3a-b09a-df047b044727
Would appreciate any help or insight into what might be causing this redirect/blank screen issue. Thank you in advance!
Distribution version
Linux
App Version
LastEst
What browsers are you seeing the problem on if you're using web version?
Chrome
Are you self-hosting?
- [x] Yes
Self-hosting Version
lastest
Relevant log output
Anything else?
No response
Issue Status: 🆕 *Untriaged
*🆕 Untriaged
The team has not yet reviewed the issue. We usually do it within one business day. Docs: https://github.com/toeverything/AFFiNE/blob/canary/docs/issue-triaging.md
This is an automatic reply by the bot.
Hi everyone! Could anyone help me with an issue I'm having with Affine?
I'd really like to use the tool, but I'm stuck on this.
"The team has not yet reviewed the issue. We usually do it within one business day." So..