# werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'index' with values ['_external']. Did you forget to specify values ['host']?

- **ID:** `python/flask-url-for-external-required`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Flask 的 url_for 函数在生成外部 URL 时缺少 host 参数

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **在应用配置中设置 SERVER_NAME** (95% success)
   ```
   app.config['SERVER_NAME'] = 'example.com'
   ```
2. **显式传递 host 参数** (90% success)
   ```
   url_for('index', _external=True, host='example.com')
   ```

## Dead Ends

- **移除 _external 参数** — 生成的 URL 可能不完整 (60% fail)
- **硬编码主机名** — 不灵活，不同环境需要修改 (70% fail)
