# Elfhosted Stremio Addon Deployment Patterns

## Common Issue: Addon at Subpath, Root Serves Something Else

Elfhosted deployments serve Stremio addons at subpaths under the same domain.
The root (`/manifest.json`) often serves a different page (PWA, portal, or redirect).

### Known Subpath Patterns

| Domain | Subpath | Root serves | Correct manifest |
|--------|---------|-------------|------------------|
| `aiostreams.elfhosted.com` | `/stremio` | PWA web manifest | `/stremio/manifest.json` |
| `comet.elfhosted.com` | `/` | Stremio addon (but 403 on streams) | `/manifest.json` |
| `mediafusion.elfhosted.com` | `/` | Stremio addon | `/manifest.json` |

### Discovery Protocol

When a Stremio addon BASE_URL returns a non-Stremio document at `/manifest.json`:

1. **Check common subpaths**:
   ```bash
   curl -s "https://example.com/stremio/manifest.json"
   curl -s "https://example.com/addon/manifest.json"
   curl -s "https://example.com/v2/manifest.json"
   curl -s "https://example.com/api/manifest.json"
   ```

2. **Check the root page** — sometimes it links to the addon:
   ```bash
   curl -s "https://example.com/" | grep -i "stremio\|manifest\|addon"
   ```

3. **Check the app's own code** for the correct URL (the `AddonsViewModel` or repository may already list the right URL even if the provider doesn't use it).

4. **Validate** the manifest has Stremio-specific fields:
   - `id` — Stremio addon IDs look like `com.example.addon` or `example.elfhosted.com`
   - `resources` array — Stremio-specific structure
   - `behaviorHints` — Stremio-specific
   - PWA manifests have `start_url`, `display`, `icons`, `theme_color` — these are NOT Stremio

5. **Test ALL endpoints** after fixing the URL:
   ```bash
   # Manifest
   curl -s "$BASE_URL/manifest.json" | python3 -m json.tool | grep "id\|version\|resources"
   # Stream
   curl -s "$BASE_URL/stream/movie/tt0133093.json"
   ```

### Stream Endpoint Does Not Mean Stremio Addon

A domain can respond to `/stream/movie/{id}.json` without `/manifest.json`
being a valid Stremio manifest. Test both independently.

### Cloudflare WAF Blocks

Elfhosted deployments use Cloudflare. Manifest endpoints are generally open,
but stream endpoints may return 403 (Cloudflare WAF) for non-browser TLS
fingerprints. If curl returns 403 but the endpoint works from the Android app
(OkHttp), document this as a deployment-specific constraint.
