Skip to content

Dashboard shows "Invalid API Key" when deployed behind external reverse proxy (Traefik) #116

@Maosalas

Description

@Maosalas

Environment

  • OpenWA version: v0.1.6
  • Deployment: Docker + external Traefik reverse proxy
  • OS: Ubuntu 24.04
  • Dashboard URL: custom domain via Traefik (e.g. wa.domain.com)
  • API URL: separate subdomain via Traefik (e.g. wa-api.domain.com)

Description

When deploying OpenWA with an external Traefik instance (not the bundled one via with-proxy profile),
the dashboard consistently shows "Invalid API Key" even when using the correct key from logs and .api-key file.

The API itself works correctly — confirmed via curl:

curl -s http://localhost:2785/api/health \
  -H "X-API-Key: <valid-key>"
# returns: {"status":"ok","timestamp":"..."}

Root Cause

The dashboard is a static React app served by Nginx. The Dockerfile.traefik builds the frontend
with the API URL hardcoded (likely http://localhost:2785), which works when both containers share
the same network but breaks in the browser because localhost resolves to the user's machine,
not the VPS.

Additionally, the default nginx/conf.d/default.conf generated by Dockerfile.traefik has no
/api proxy block:

server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html;
    index index.html;
    location / {
        try_files $uri $uri/ /index.html;
    }
}

Fix Applied

Adding a proxy block to the Nginx config so /api requests are forwarded to the openwa-api container:

server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html;
    index index.html;

    location /api {
        proxy_pass http://openwa-api:2785;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location / {
        try_files $uri $uri/ /index.html;
    }
}

Suggested Fix

The Dockerfile.traefik or the dashboard's nginx/conf.d/default.conf should include the /api
proxy block by default, or the React app should support a runtime VITE_API_URL environment variable
so users can point the dashboard to the correct API URL without rebuilding.

Steps to Reproduce

  1. Clone the repo
  2. Deploy with docker compose up -d using docker-compose.override.yml with external Traefik labels
  3. Access dashboard via public domain
  4. Enter valid API key → "Invalid API Key" error

Additional Notes

  • The bundled with-proxy profile (internal Traefik) was not tested — this issue is specific to
    users bringing their own reverse proxy.
  • The API key itself is valid and works via direct curl to the API container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions