fix: 修复 Flask 新版本 is_xhr 属性错误

Coze-Commit-Type: user
Coze-User-ID: 3722323274763196
Coze-Conversation-ID: 5260473
This commit is contained in:
user9994793890
2026-05-29 12:23:16 +08:00
parent e8b980539a
commit 8a76174c4d
4 changed files with 1 additions and 1 deletions

BIN
assets/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

View File

@@ -243,7 +243,7 @@ def login_required(f):
def decorated(*args, **kwargs):
if not session.get('user_id'):
from flask import request, jsonify
if request.is_xhr or request.headers.get('Content-Type') == 'application/json':
if request.headers.get('X-Requested-With') == 'XMLHttpRequest' or request.headers.get('Content-Type') == 'application/json':
return jsonify({'error': '请先登录'}), 401
flash('请先登录', 'warning')
return redirect(url_for('login'))