Skip to content

Commit 9185ef0

Browse files
kriszypclaude
andcommitted
fix(unitTests/testApp): use HARPER_TEST_HOST for CacheOfHttp self-fetches
resources.js runs inside the Harper instance and fetches back from itself via HTTP. When the test server is bound to a loopback address other than localhost, the hardcoded http://localhost:9926 fetch fails. Read HARPER_TEST_HOST (set by setupTestApp) to build the correct origin. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c5c9d65 commit 9185ef0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

unitTests/testApp/resources.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ tables.CacheOfResource.sourcedFrom({
170170

171171
// test transparent HTTP caching straight through
172172
tables.CacheOfHttp.serverErrorCalls = 0;
173+
const cacheSourceBase = `http://${process.env.HARPER_TEST_HOST || 'localhost'}:9926`;
173174
tables.CacheOfHttp.sourcedFrom({
174175
async get(target) {
175176
switch (target) {
176177
case 'direct-fetch':
177-
return fetch(`http://localhost:9926/FourProp/2`);
178+
return fetch(`${cacheSourceBase}/FourProp/2`);
178179
case 'fetch-body':
179-
const response = await fetch(`http://localhost:9926/FourProp/2`);
180+
const response = await fetch(`${cacheSourceBase}/FourProp/2`);
180181
return new Response(response.body, {
181182
headers: {
182183
'Content-Type': 'text/plain',

0 commit comments

Comments
 (0)