Skip to content

Commit e6aec2d

Browse files
committed
fix(LeanEngine): X-LC-Prod request header
Previously, the X-LC-Prod header was `1` (production) in stage instance, which causes data modifications in stage environment triggers hooks in production environment. This commit fixes this issue, the X-LC-Prod will be set according to environment variables: - whether in stage or production instance - whether the user has a stage instance (when debug locally) Related support ticket: 20333
1 parent fea3240 commit e6aec2d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

leancloud/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@
2525
APP_KEY = None
2626
MASTER_KEY = None
2727
HOOK_KEY = None
28-
USE_PRODUCTION = '1'
28+
if os.getenv('LEANCLOUD_APP_ENV') == 'production':
29+
USE_PRODUCTION = '1'
30+
elif os.getenv('LEANCLOUD_APP_ENV') == 'stage':
31+
USE_PRODUCTION = '0'
32+
else: # probably on local machine
33+
if os.getenv('LEAN_CLI_HAVE_STAGING') == 'true':
34+
USE_PRODUCTION = '0'
35+
else: # free trial instance only
36+
USE_PRODUCTION = '1'
37+
2938
USE_HTTPS = True
3039
# 兼容老版本,如果 USE_MASTER_KEY 为 None ,并且 MASTER_KEY 不为 None,则使用 MASTER_KEY
3140
# 否则依据 USE_MASTER_KEY 来决定是否使用 MASTER_KEY

0 commit comments

Comments
 (0)