refactor(agents): use authorization headers instead of param for token
This commit is contained in:
parent
9b0d307620
commit
d1f872573e
3 changed files with 9 additions and 7 deletions
|
|
@ -121,8 +121,8 @@ export function createAgentManagerRuntime() {
|
|||
Bun.serve<AgentConnectionData>({
|
||||
port: 3001,
|
||||
async fetch(req, srv) {
|
||||
const url = new URL(req.url);
|
||||
const token = url.searchParams.get("token");
|
||||
const authorizationHeader = req.headers.get("authorization");
|
||||
const token = authorizationHeader?.slice("Bearer ".length);
|
||||
|
||||
if (!token) {
|
||||
return new Response("Missing token", { status: 401 });
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ class Agent {
|
|||
}
|
||||
|
||||
const url = new URL(controllerUrl);
|
||||
url.searchParams.set("token", agentToken);
|
||||
|
||||
this.ws = new WebSocket(url.toString());
|
||||
this.ws = new WebSocket(url.toString(), {
|
||||
headers: {
|
||||
authorization: `Bearer ${agentToken}`,
|
||||
},
|
||||
});
|
||||
this.controllerSession = createControllerSession(this.ws);
|
||||
|
||||
this.ws.onopen = () => {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
"compilerOptions": {
|
||||
"plugins": [{ "name": "@effect/language-service" }],
|
||||
// Environment setup & latest features
|
||||
"lib": ["DOM", "ESNext"],
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"types": ["bun", "node"],
|
||||
"types": ["node", "bun"],
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
|
|
|
|||
Loading…
Reference in a new issue