File tree Expand file tree Collapse file tree 8 files changed +45
-4
lines changed Expand file tree Collapse file tree 8 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ The AgentAPI module is a building block for modules that need to run an AgentAPI
16
16
``` tf
17
17
module "agentapi" {
18
18
source = "registry.coder.com/coder/agentapi/coder"
19
- version = "1.1.0 "
19
+ version = "1.1.1 "
20
20
21
21
agent_id = var.agent_id
22
22
web_app_slug = local.app_slug
Original file line number Diff line number Diff line change @@ -236,4 +236,17 @@ describe("agentapi", async () => {
236
236
}
237
237
}
238
238
} ) ;
239
+
240
+ test ( "agentapi-allowed-hosts" , async ( ) => {
241
+ // verify that the agentapi binary has access to the AGENTAPI_ALLOWED_HOSTS environment variable
242
+ // set in main.sh
243
+ const { id } = await setup ( ) ;
244
+ await execModuleScript ( id ) ;
245
+ await expectAgentAPIStarted ( id ) ;
246
+ const agentApiStartLog = await readFileContainer (
247
+ id ,
248
+ "/home/coder/agentapi-mock.log" ,
249
+ ) ;
250
+ expect ( agentApiStartLog ) . toContain ( "AGENTAPI_ALLOWED_HOSTS: *" ) ;
251
+ } ) ;
239
252
} ) ;
Original file line number Diff line number Diff line change @@ -95,5 +95,7 @@ export LC_ALL=en_US.UTF-8
95
95
cd " ${WORKDIR} "
96
96
97
97
export AGENTAPI_CHAT_BASE_PATH=" ${AGENTAPI_CHAT_BASE_PATH:- } "
98
+ # Disable host header check since AgentAPI is proxied by Coder (which does its own validation)
99
+ export AGENTAPI_ALLOWED_HOSTS=" *"
98
100
nohup " $module_path /scripts/agentapi-start.sh" true " ${AGENTAPI_PORT} " & > " $module_path /agentapi-start.log" &
99
101
" $module_path /scripts/agentapi-wait-for-start.sh" " ${AGENTAPI_PORT} "
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
3
const http = require ( "http" ) ;
4
+ const fs = require ( "fs" ) ;
4
5
const args = process . argv . slice ( 2 ) ;
5
6
const portIdx = args . findIndex ( ( arg ) => arg === "--port" ) + 1 ;
6
7
const port = portIdx ? args [ portIdx ] : 3284 ;
7
8
8
9
console . log ( `starting server on port ${ port } ` ) ;
10
+ fs . writeFileSync ( "/home/coder/agentapi-mock.log" , `AGENTAPI_ALLOWED_HOSTS: ${ process . env . AGENTAPI_ALLOWED_HOSTS } ` ) ;
9
11
10
12
http
11
13
. createServer ( function ( _request , response ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
13
13
``` tf
14
14
module "claude-code" {
15
15
source = "registry.coder.com/coder/claude-code/coder"
16
- version = "2.0.6 "
16
+ version = "2.0.7 "
17
17
agent_id = coder_agent.example.id
18
18
folder = "/home/coder"
19
19
install_claude_code = true
@@ -84,7 +84,7 @@ resource "coder_agent" "main" {
84
84
module "claude-code" {
85
85
count = data.coder_workspace.me.start_count
86
86
source = "registry.coder.com/coder/claude-code/coder"
87
- version = "2.0.6 "
87
+ version = "2.0.7 "
88
88
agent_id = coder_agent.example.id
89
89
folder = "/home/coder"
90
90
install_claude_code = true
@@ -102,7 +102,7 @@ Run Claude Code as a standalone app in your workspace. This will install Claude
102
102
``` tf
103
103
module "claude-code" {
104
104
source = "registry.coder.com/coder/claude-code/coder"
105
- version = "2.0.6 "
105
+ version = "2.0.7 "
106
106
agent_id = coder_agent.example.id
107
107
folder = "/home/coder"
108
108
install_claude_code = true
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import path from "path";
10
10
import {
11
11
execContainer ,
12
12
findResourceInstance ,
13
+ readFileContainer ,
13
14
removeContainer ,
14
15
runContainer ,
15
16
runTerraformApply ,
@@ -319,4 +320,21 @@ describe("claude-code", async () => {
319
320
agentApiUrl : "http://localhost:3284" ,
320
321
} ) ;
321
322
} ) ;
323
+
324
+ // verify that the agentapi binary has access to the AGENTAPI_ALLOWED_HOSTS environment variable
325
+ // set in main.tf
326
+ test ( "agentapi-allowed-hosts" , async ( ) => {
327
+ const { id } = await setup ( ) ;
328
+
329
+ const respModuleScript = await execModuleScript ( id ) ;
330
+ expect ( respModuleScript . exitCode ) . toBe ( 0 ) ;
331
+
332
+ await expectAgentAPIStarted ( id ) ;
333
+
334
+ const agentApiStartLog = await readFileContainer (
335
+ id ,
336
+ "/home/coder/agentapi-mock.log" ,
337
+ ) ;
338
+ expect ( agentApiStartLog ) . toContain ( "AGENTAPI_ALLOWED_HOSTS: *" ) ;
339
+ } ) ;
322
340
} ) ;
Original file line number Diff line number Diff line change @@ -241,6 +241,10 @@ resource "coder_script" "claude_code" {
241
241
export LC_ALL=en_US.UTF-8
242
242
243
243
cd "${ local . workdir } "
244
+
245
+ # Disable host header check since AgentAPI is proxied by Coder (which does its own validation)
246
+ export AGENTAPI_ALLOWED_HOSTS="*"
247
+
244
248
nohup "$module_path/scripts/agentapi-start.sh" use_prompt &> "$module_path/agentapi-start.log" &
245
249
"$module_path/scripts/agentapi-wait-for-start.sh"
246
250
EOT
Original file line number Diff line number Diff line change 20
20
process . exit ( 1 ) ;
21
21
}
22
22
23
+ fs . writeFileSync ( "/home/coder/agentapi-mock.log" , `AGENTAPI_ALLOWED_HOSTS: ${ process . env . AGENTAPI_ALLOWED_HOSTS } ` ) ;
24
+
23
25
console . log ( `starting server on port ${ port } ` ) ;
24
26
25
27
http
You can’t perform that action at this time.
0 commit comments