# Werkzeug路由异常：无法为端点'login'构建URL

- **ID:** `python/flask-redirect-endpoint-error`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

url_for或redirect中使用的端点名称与任何定义的路由不匹配，或缺少必需的参数。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Check the route decorator: @app.route('/login', endpoint='login') or ensure the function name matches.
   ```
2. **** (90% 成功率)
   ```
   Provide required parameters: url_for('user_profile', username='john')
   ```

## 无效尝试

- **** — Using a hardcoded URL instead of url_for can break if routes change. (50% 失败率)
- **** — Adding a route with a different name does not fix the endpoint mismatch. (70% 失败率)
