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
1616``` tf
1717module "agentapi" {
1818 source = "registry.coder.com/coder/agentapi/coder"
19- version = "1.1.0 "
19+ version = "1.1.1 "
2020
2121 agent_id = var.agent_id
2222 web_app_slug = local.app_slug
Original file line number Diff line number Diff line change @@ -236,4 +236,17 @@ describe("agentapi", async () => {
236236 }
237237 }
238238 } ) ;
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+ } ) ;
239252} ) ;
Original file line number Diff line number Diff line change @@ -95,5 +95,7 @@ export LC_ALL=en_US.UTF-8
9595cd " ${WORKDIR} "
9696
9797export 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=" *"
98100nohup " $module_path /scripts/agentapi-start.sh" true " ${AGENTAPI_PORT} " & > " $module_path /agentapi-start.log" &
99101" $module_path /scripts/agentapi-wait-for-start.sh" " ${AGENTAPI_PORT} "
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
33const http = require ( "http" ) ;
4+ const fs = require ( "fs" ) ;
45const args = process . argv . slice ( 2 ) ;
56const portIdx = args . findIndex ( ( arg ) => arg === "--port" ) + 1 ;
67const port = portIdx ? args [ portIdx ] : 3284 ;
78
89console . log ( `starting server on port ${ port } ` ) ;
10+ fs . writeFileSync ( "/home/coder/agentapi-mock.log" , `AGENTAPI_ALLOWED_HOSTS: ${ process . env . AGENTAPI_ALLOWED_HOSTS } ` ) ;
911
1012http
1113 . 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
1313``` tf
1414module "claude-code" {
1515 source = "registry.coder.com/coder/claude-code/coder"
16- version = "2.0.6 "
16+ version = "2.0.7 "
1717 agent_id = coder_agent.example.id
1818 folder = "/home/coder"
1919 install_claude_code = true
@@ -84,7 +84,7 @@ resource "coder_agent" "main" {
8484module "claude-code" {
8585 count = data.coder_workspace.me.start_count
8686 source = "registry.coder.com/coder/claude-code/coder"
87- version = "2.0.6 "
87+ version = "2.0.7 "
8888 agent_id = coder_agent.example.id
8989 folder = "/home/coder"
9090 install_claude_code = true
@@ -102,7 +102,7 @@ Run Claude Code as a standalone app in your workspace. This will install Claude
102102``` tf
103103module "claude-code" {
104104 source = "registry.coder.com/coder/claude-code/coder"
105- version = "2.0.6 "
105+ version = "2.0.7 "
106106 agent_id = coder_agent.example.id
107107 folder = "/home/coder"
108108 install_claude_code = true
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import path from "path";
1010import {
1111 execContainer ,
1212 findResourceInstance ,
13+ readFileContainer ,
1314 removeContainer ,
1415 runContainer ,
1516 runTerraformApply ,
@@ -319,4 +320,21 @@ describe("claude-code", async () => {
319320 agentApiUrl : "http://localhost:3284" ,
320321 } ) ;
321322 } ) ;
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+ } ) ;
322340} ) ;
Original file line number Diff line number Diff line change @@ -241,6 +241,10 @@ resource "coder_script" "claude_code" {
241241 export LC_ALL=en_US.UTF-8
242242
243243 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+
244248 nohup "$module_path/scripts/agentapi-start.sh" use_prompt &> "$module_path/agentapi-start.log" &
245249 "$module_path/scripts/agentapi-wait-for-start.sh"
246250 EOT
Original file line number Diff line number Diff line change 2020 process . exit ( 1 ) ;
2121}
2222
23+ fs . writeFileSync ( "/home/coder/agentapi-mock.log" , `AGENTAPI_ALLOWED_HOSTS: ${ process . env . AGENTAPI_ALLOWED_HOSTS } ` ) ;
24+
2325console . log ( `starting server on port ${ port } ` ) ;
2426
2527http
You can’t perform that action at this time.
0 commit comments