Skip to content
Open
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
64 changes: 64 additions & 0 deletions Caddyfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
# Use internal CA for self-signed certificates
local_certs
# Enable debug logging
debug
}

# Scenario 1: Single-host WITHOUT sub-path
# Direct proxy to Fider
fider.local {
reverse_proxy fider-single:3000
log {
output stdout
format console
}
}

# Scenario 2: Single-host WITH sub-path
# Root serves a simple landing page, /feedback/* routes to Fider
app.local {
# Root path - simple HTML landing page
handle / {
respond `<!DOCTYPE html>
<html>
<head><title>App Landing</title></head>
<body style="font-family: sans-serif; max-width: 800px; margin: 50px auto; padding: 20px;">
<h1>App Landing Page</h1>
<p>This simulates a main application at the root path.</p>
<p><a href="/feedback">Go to Feedback (Fider)</a></p>
<hr>
<p style="color: gray;">Testing scenario: Single-host with Fider at /feedback sub-path</p>
</body>
</html>` 200
}

# Fider at /feedback sub-path
handle /feedback* {
reverse_proxy fider-subpath:3000
}

log {
output stdout
format console
}
}

# Scenario 3: Multi-host WITHOUT sub-path
# Wildcard subdomain routing
*.multi.local {
reverse_proxy fider-multi:3000
log {
output stdout
format console
}
}

# Multi-host root domain for initial setup
multi.local {
reverse_proxy fider-multi:3000
log {
output stdout
format console
}
}
138 changes: 138 additions & 0 deletions QUICK-TEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Quick Test Guide

Fast setup to test sub-path hosting locally with HTTPS.

## 1. Setup hosts file

**Windows (run as Administrator):**
```powershell
.\setup-hosts.ps1
```

**Linux/Mac:**
```bash
chmod +x setup-hosts.sh
sudo ./setup-hosts.sh
```

Or manually add to your hosts file:
```
127.0.0.1 fider.local
127.0.0.1 app.local
127.0.0.1 multi.local
127.0.0.1 tenant1.multi.local
127.0.0.1 tenant2.multi.local
```

## 2. Pull the test image

```bash
docker pull ghcr.io/3rg0n/fider:subpath-fix
```

If the image is private, authenticate first:
```bash
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
```

## 3. Start the test environment

```bash
docker-compose -f docker-compose-test.yml up -d
```

Wait ~10 seconds for all services to start, then check:
```bash
docker-compose -f docker-compose-test.yml ps
```

All services should show "Up" status.

## 4. Run the tests

### Test Scenario 1: Single-host (no sub-path)
Open: https://fider.local

Accept the certificate warning, complete setup wizard.

**Quick checks:**
- Homepage at `/`
- Create a post, verify redirect to `/posts/{id}/...`
- Delete post, verify redirect to `/`

### Test Scenario 2: Single-host WITH sub-path (THE FIX)
Open: https://app.local

You should see a landing page. Click "Go to Feedback".

Open: https://app.local/feedback

**Critical checks:**
- Homepage at `/feedback` (not `/`)
- Create post → redirects to `/feedback/posts/{id}/...`
- Delete post → redirects to `/feedback/` (not `/`)
- All links include `/feedback` prefix
- DevTools Network tab: API calls go to `/feedback/api/v1/...`

### Test Scenario 3: Multi-host (no sub-path)
Open: https://multi.local

Create tenant with subdomain `tenant1`.

Open: https://tenant1.multi.local

**Quick checks:**
- Homepage at `/` (tenant subdomain)
- Create/delete posts work with root-relative paths
- No `/feedback` prefix anywhere

## 5. View logs

```bash
docker-compose -f docker-compose-test.yml logs -f
```

## 6. Cleanup

```bash
docker-compose -f docker-compose-test.yml down -v
```

---

## Troubleshooting

**Certificate warnings:**
Normal for self-signed certs. Click "Advanced" → "Proceed".

**Port conflicts:**
If ports 80/443 are in use:
```bash
# Stop conflicting services
# On Windows: Stop IIS or other web servers
# On Linux: sudo systemctl stop nginx/apache2
```

**Services not starting:**
```bash
# Check logs
docker-compose -f docker-compose-test.yml logs postgres
docker-compose -f docker-compose-test.yml logs caddy
```

**Database connection errors:**
Wait for postgres health check:
```bash
docker-compose -f docker-compose-test.yml ps postgres
# Should show "(healthy)"
```

**Image pull fails:**
Make the package public at:
https://github.com/users/3rg0n/packages/container/fider/settings

Or authenticate with GITHUB_TOKEN that has `read:packages` scope.

---

For detailed test checklists, see: **TEST-SCENARIOS.md**
114 changes: 114 additions & 0 deletions TEST-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Sub-Path Hosting Test Suite

Complete test environment for verifying sub-path hosting support across all Fider deployment modes.

## Files in this test suite

- **TEST-SCENARIOS.md** - Detailed test scenarios and checklists for each deployment mode
- **QUICK-TEST.md** - Fast setup guide to get testing quickly
- **docker-compose-test.yml** - Multi-scenario test environment with Caddy reverse proxy
- **Caddyfile.test** - Caddy configuration for HTTPS with self-signed certificates
- **setup-hosts.sh** - Linux/Mac script to configure hosts file
- **setup-hosts.ps1** - Windows script to configure hosts file
- **TESTING.md** - Test matrix documentation for PR review

## What gets tested

### ✅ Scenario 1: Single-host without sub-path
- **URL:** https://fider.local
- **Config:** `HOST_MODE=single`, `BASE_URL=https://fider.local`
- **Tests:** Standard Fider at domain root (existing functionality)

### ✅ Scenario 2: Single-host WITH sub-path (THE PRIMARY FIX)
- **URL:** https://app.local/feedback
- **Config:** `HOST_MODE=single`, `BASE_URL=https://app.local/feedback`
- **Tests:** Fider under sub-path with root landing page (new functionality)

### ✅ Scenario 3: Multi-host without sub-path
- **URLs:** https://tenant1.multi.local, https://tenant2.multi.local
- **Config:** `HOST_MODE=multi`, `HOST_DOMAIN=multi.local`
- **Tests:** Multiple tenants via subdomains (existing functionality)

## Quick Start

```bash
# 1. Setup hosts file (Windows: run PowerShell as Admin)
.\setup-hosts.ps1 # Windows
sudo ./setup-hosts.sh # Linux/Mac

# 2. Pull test image
docker pull ghcr.io/3rg0n/fider:subpath-fix

# 3. Start test environment
docker-compose -f docker-compose-test.yml up -d

# 4. Test each scenario
# - https://fider.local (single-host, no sub-path)
# - https://app.local/feedback (single-host WITH sub-path)
# - https://multi.local (multi-host setup)

# 5. Cleanup
docker-compose -f docker-compose-test.yml down -v
```

## Making the test image public

If you get authentication errors pulling the image, make it public:

1. Go to: https://github.com/users/3rg0n/packages/container/fider/settings
2. Scroll to "Danger Zone"
3. Click "Change visibility" → "Public"
4. Confirm the change

Alternatively, authenticate:
```bash
echo $GITHUB_TOKEN | docker login ghcr.io -u 3rg0n --password-stdin
```

## Test Checklist

After testing all scenarios, document results in TESTING.md:

- [ ] Single-host without sub-path: All navigation and API calls work
- [ ] Single-host WITH sub-path: All paths include `/feedback` prefix
- [ ] Multi-host: Each tenant isolated with root-relative paths
- [ ] HTTPS works with self-signed certificates
- [ ] No JavaScript console errors
- [ ] No 404 errors in Network tab
- [ ] OAuth redirects use correct BASE_URL (if configured)

## Architecture

```
┌─────────────────────────────────────────────────────────┐
│ Caddy (HTTPS) │
│ Automatic Self-Signed Certs │
└──────────────────┬──────────────────────────────────────┘
┌─────────┼──────────┐
│ │ │
fider.local app.local *.multi.local
│ │ │
▼ ▼ ▼
┌────────┐ ┌─────────┐ ┌──────────┐
│Fider │ │Landing +│ │Fider │
│Single │ │Fider at │ │Multi │
│No path │ │/feedback│ │Subdomains│
└────────┘ └─────────┘ └──────────┘
│ │ │
└─────────┴──────────┘
PostgreSQL
```

## Related PRs

- **#1454** - Core Context.BaseURL() fix
- **#1455** - Full sub-path hosting support

## Maintainer Review

This test suite addresses the maintainer's request to:
> test against all supported types of installation [...] single host as is now, and on a sub-path, and the same for multi-host

Results documented in TESTING.md after running all scenarios.
Loading