我从 Azure 日志中收到以下错误消息:
Result: Failure Exception: KeyError: 'referer' Stack: File "/azure-functions-
host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 372, in
_handle__invocation_request self.__run_sync_func, invocation_id, fi.func, args) File
"/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args,
**self.kwargs) File "/azure-functions
host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 548, in __run_sync_func
return func(**params) File "/home/site/wwwroot/createCheckoutSession/__init__.py", line 18, in main
logging.info(req.headers["referer"]) File "/azure-functions-
host/workers/python/3.7/LINUX/X64/azure/functions/_http.py", line 27, in __getitem__ return
self.__http_headers__[key.lower()]
我认为有问题的代码是:
logging.info(req.headers["referer"])
logging.info(os.environ["stripe_api_key"])
BASEURL = req.headers["referer"] + "#"
Azure 似乎正在努力从 req.headers 中提取引用。它适用于 VScode。在 Stripe 支付请求后,我使用引荐来源网址构建重定向 URL。这种重定向在 DEV、TEST 和 PROD 中明显不同。任何想法我做错了什么。
