paperclip/docs
Chris Farhood b816809a1e
fix(server): respect externally set PAPERCLIP_API_URL env var (#3472)
## Thinking Path

> - Paperclip server starts up and sets internal `PAPERCLIP_API_URL` for
downstream services and adapters
> - The server startup code was unconditionally overwriting
`PAPERCLIP_API_URL` with `http://localhost:3100` (or equivalent based on
`config.host`)
> - In Kubernetes deployments, `PAPERCLIP_API_URL` is set via a
ConfigMap to the externally accessible load balancer URL (e.g.
`https://paperclip.example.com`)
> - Because the env var was unconditionally set after loading the
ConfigMap value, the ConfigMap-provided URL was ignored and replaced
with the internal localhost address
> - This caused downstream services (adapter env building) to use the
wrong URL, breaking external access
> - This pull request makes the assignment conditional — only set if not
already provided by the environment
> - External deployments can now supply `PAPERCLIP_API_URL` and it will
be respected; local development continues to work without setting it

## What Changed

- `server/src/index.ts`: Wrapped `PAPERCLIP_API_URL` assignment in `if
(!process.env.PAPERCLIP_API_URL)` guard so externally provided values
are preserved
- `server/src/__tests__/server-startup-feedback-export.test.ts`: Added
tests verifying external `PAPERCLIP_API_URL` is respected and fallback
behavior is correct
- `docs/deploy/environment-variables.md`: Updated `PAPERCLIP_API_URL`
description to clarify it can be externally provided and the load
balancer/reverse proxy use case

## Verification

- Run the existing test suite: `pnpm test:run
server/src/__tests__/server-startup-feedback-export.test.ts` — all 3
tests pass
- Manual verification: Set `PAPERCLIP_API_URL` to a custom value before
starting the server and confirm it is not overwritten

## Risks

- Low risk — purely additive conditional check; existing behavior for
unset env var is unchanged

## Model Used

MiniMax M2.7 — reasoning-assisted for tracing the root cause through the
startup chain (`buildPaperclipEnv` → `startServer` → `config.host` →
`HOST` env var)

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Pawla Abdul (Bot) <pawla@groombook.dev>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-15 06:43:48 -05:00
..
adapters fix(codex-local): avoid fast mode in env probe 2026-04-11 08:33:18 -05:00
api [codex] Harden execution reliability and heartbeat tooling (#3679) 2026-04-14 13:34:52 -05:00
cli Introduce bind presets for deployment setup 2026-04-11 07:09:07 -05:00
companies Add routine support to recurring task portability 2026-03-23 16:57:38 -05:00
deploy fix(server): respect externally set PAPERCLIP_API_URL env var (#3472) 2026-04-15 06:43:48 -05:00
guides [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
images fix: restore docs deleted in v0.2.3 release, add Paperclip branding 2026-03-03 15:49:43 -06:00
plans feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
specs Add company import export v2 plan 2026-03-13 21:10:45 -05:00
start Make onboarding reruns preserve existing config 2026-03-29 10:51:58 -05:00
agents-runtime.md fix(adapters): restore built-in Hermes and sync lockfile with server 2026-04-03 21:11:21 +01:00
docs.json feat(adapters): external adapter plugin system with dynamic UI parser 2026-04-03 21:11:20 +01:00
favicon.svg fix: restore docs deleted in v0.2.3 release, add Paperclip branding 2026-03-03 15:49:43 -06:00
feedback-voting.md Restore feedback trace export fixes 2026-04-03 15:59:42 -05:00