fix: 修复 Flask 新版本 is_xhr 属性错误
Coze-Commit-Type: user Coze-User-ID: 3722323274763196 Coze-Conversation-ID: 5260473
This commit is contained in:
BIN
assets/image.png
Normal file
BIN
assets/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user