4.1 KiB
Umami Website Creation Not Working - Debug Steps
Issue
The Umami website is not being created during setup, resulting in 400 Bad Request errors from the tracking script.
Debug Steps
1. Check Backend Logs
Look at your backend console/terminal output when you access the setup page. You should see one of these messages:
Success:
INFO: Umami website ensured for dev domain localhost (ID: abc-123-def)
Failure:
ERROR: Auto-ensure Umami website (dev) failed: <error details>
2. Test Umami Connection Manually
Open a new PowerShell window and test the connection:
# Test 1: Login to Umami
$body = @{
username = "admin"
password = "eevRQ6h3G@!c#y4A1T"
} | ConvertTo-Json
$response = Invoke-RestMethod -Uri "https://umami.tdvorak.dev/api/auth/login" `
-Method Post `
-ContentType "application/json" `
-Body $body
Write-Output "Token received: $($response.token.Substring(0,50))..."
# Test 2: List existing websites
$token = $response.token
$headers = @{
Authorization = "Bearer $token"
}
$websites = Invoke-RestMethod -Uri "https://umami.tdvorak.dev/api/websites" `
-Headers $headers `
-Method Get
Write-Output "Existing websites:"
$websites.data | Format-Table name, domain, id
3. Check Environment Variables
Verify your .env file has all required values:
UMAMI_URL=https://umami.tdvorak.dev
UMAMI_USERNAME=admin
UMAMI_PASSWORD=eevRQ6h3G@!c#y4A1T
UMAMI_WEBSITE_ID= # Empty (will be auto-created)
APP_ENV=development # Important: allows localhost
4. Restart Backend
After verifying .env, restart your backend:
# Stop current backend (Ctrl+C)
# Then restart
go run main.go
# or
./fotbal-club
5. Test Auto-Creation via API
After backend restart, test the endpoint directly:
# Call the config endpoint to trigger auto-creation
Invoke-RestMethod -Uri "http://localhost:8080/api/v1/umami/config" `
-Method Get
# Should return:
# {
# "enabled": true,
# "website_id": "abc-123-def",
# "script_url": "https://umami.tdvorak.dev/script.js"
# }
6. Manual Creation via Admin Panel
If auto-creation fails, use the manual UI:
- Login to your admin panel
- Go to Settings → Umami Analytics tab
- Fill in:
- Name: "My Football Club"
- Domain: "localhost" (for development)
- Click "Vytvořit webovou stránku" (Create Website)
- Copy the Website ID
- Add to
.env:UMAMI_WEBSITE_ID=<the-id-you-got> - Restart backend
Common Issues
Issue: "authentication failed"
Cause: Umami credentials are wrong
Fix: Verify UMAMI_USERNAME and UMAMI_PASSWORD in .env match your Umami admin credentials
Issue: "domain already exists"
Cause: Website for "localhost" was created before Solution:
- Login to Umami dashboard (https://umami.tdvorak.dev)
- Find the existing website
- Copy its ID
- Add to
.env:UMAMI_WEBSITE_ID=<existing-id> - Restart backend
Issue: Silent failure (no logs)
Cause: Backend is not reaching the auto-creation code Fix:
- Ensure you're calling
/api/v1/umami/config(not just loading the page) - Check if
APP_ENV=developmentin.env - Verify backend is running and accessible
Issue: "400 Bad Request" from script.js
Cause: Website ID doesn't exist in Umami Fix: This is the symptom, not the cause. Follow steps 1-5 above to create the website first.
Next Steps
- Check backend logs - This will tell you exactly what's failing
- Test PowerShell connection - Verifies Umami credentials work
- Try manual creation - Bypasses auto-creation issues
- Report back - Share the error message from backend logs
Expected Backend Log Output
When working correctly, you should see:
INFO: Successfully authenticated with Umami (new token issued)
INFO: Umami website ensured for dev domain localhost (ID: 12345678-abcd-1234-abcd-123456789012)
INFO: GET /api/v1/umami/config 200
When failing, you'll see:
ERROR: Auto-ensure Umami website (dev) failed: authentication failed with status 401
or
ERROR: Auto-ensure Umami website (dev) failed: failed to create website: <details>