Z User commited on
Commit
4dda966
·
1 Parent(s): f90569c

fix(phase4): forward X-Bot-Api-Key and X-Internal-Call headers through proxy

Browse files

The web-server proxy was stripping the X-Bot-Api-Key header, so all bot_* ops on
cross-platform were returning 401. Now we explicitly forward:
- X-Bot-Api-Key (so the Render WhatsApp bot can authenticate)
- X-Internal-Call (so edge functions can call each other for telegram broadcasts)

Files changed (1) hide show
  1. web-server/server.py +11 -0
web-server/server.py CHANGED
@@ -101,6 +101,17 @@ async def _proxy_to_edge_function(edge_name: str, request: Request):
101
  # in the web_sessions table to get the actual JWT access_token
102
  outgoing_headers["Authorization"] = f"Bearer {session_id}"
103
 
 
 
 
 
 
 
 
 
 
 
 
104
  # Read the request body
105
  try:
106
  body = await request.body()
 
101
  # in the web_sessions table to get the actual JWT access_token
102
  outgoing_headers["Authorization"] = f"Bearer {session_id}"
103
 
104
+ # Phase 4: forward X-Bot-Api-Key so the WhatsApp bot can call cross-platform endpoints
105
+ # (used by the Render WhatsApp bot to add to cart, link accounts, etc.)
106
+ bot_api_key = request.headers.get("X-Bot-Api-Key")
107
+ if bot_api_key:
108
+ outgoing_headers["X-Bot-Api-Key"] = bot_api_key
109
+
110
+ # Phase 4: forward X-Internal-Call so edge functions can call each other (e.g. telegram broadcast)
111
+ internal_call = request.headers.get("X-Internal-Call")
112
+ if internal_call:
113
+ outgoing_headers["X-Internal-Call"] = internal_call
114
+
115
  # Read the request body
116
  try:
117
  body = await request.body()