Skip to content

Commit 9d1d0c3

Browse files
committed
fix: explicit route for index.html to ensure server token injection over static file routing
1 parent 280ea0c commit 9d1d0c3

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ async def index(req: Request) -> Response:
9494

9595
APP = web.Application()
9696
APP.router.add_post("/api/messages", messages)
97-
APP.router.add_get("/", index)
9897

9998
import os as _os
10099
if _os.path.isdir("web"):
100+
APP.router.add_get("/", index)
101+
APP.router.add_get("/index.html", index)
101102
APP.router.add_static("/", "web")
102103

103104
if __name__ == "__main__":

test_token.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import asyncio
2+
import aiohttp
3+
from config import DefaultConfig
4+
5+
async def test_token():
6+
config = DefaultConfig()
7+
secret = config.WEB_CHAT_SECRET
8+
print(f"Secret: {secret}")
9+
10+
async with aiohttp.ClientSession() as session:
11+
headers = {"Authorization": f"Bearer {secret}"}
12+
async with session.get("https://webchat.botframework.com/api/tokens", headers=headers) as resp:
13+
print(f"Status: {resp.status}")
14+
text = await resp.text()
15+
print(f"Token: {text}")
16+
17+
if __name__ == "__main__":
18+
asyncio.run(test_token())

0 commit comments

Comments
 (0)