Skip to content

One home for the proxy's PUBLIC parsing and mode precedence - #131

Open
jonocodes wants to merge 1 commit into
mainfrom
refactor/proxy-parse-public
Open

jonocodes wants to merge 1 commit into
mainfrom
refactor/proxy-parse-public

Conversation

@jonocodes

Copy link
Copy Markdown
Owner

Follow-up to #125 (#124), from its code review. This is a refactor with no behaviour change.

String(env.PUBLIC || "").toLowerCase() === "true" was copied three times: once in worker.js and twice in node.js. node.js also re-implemented core's "PUBLIC wins over PROXY_TOKENS" rule for its startup log line, so the shells could drift from core.

Change

  • core.js exports two new helpers:
    • parsePublic(raw): only "true" (any case) opens the proxy. Anything else fails closed, as before, including stray whitespace (ADR 0002).
    • proxyMode({ tokens, isPublic }) returns "public", "locked" or "unconfigured".
  • handleRequest now branches on proxyMode. This covers the setup page, the token check and health's authRequired.
  • worker.js and node.js use parsePublic. The Node startup log uses proxyMode, and now prints locked instead of token-locked.

Tests

  • New unit tests for parsePublic and proxyMode in worker.test.mjs. They failed before the change (missing exports).
  • node --test in infra/cors-worker: 103/103, including the shared suite on both shells.
  • Starting node.js with each configuration logs the expected mode.

This touches core.js, so it changes the Cloudflare bundle. The behaviour is covered by the existing Cloudflare tests.

🤖 Generated with Claude Code

…low-up)

`String(env.PUBLIC || "").toLowerCase() === "true"` was copied into
worker.js and twice into node.js, and node.js re-derived core's "PUBLIC wins
over tokens" rule for its startup log. Core now exports parsePublic and
proxyMode, uses proxyMode itself, and both shells call them. Behaviour is
unchanged: only "true" (any case) opens the proxy; anything else fails closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for savrlist ready!

Name Link
🔨 Latest commit 12d54ad
🔍 Latest deploy log https://app.netlify.com/projects/savrlist/deploys/6ad7c4e5ffe906e296b2515c
😎 Deploy Preview https://deploy-preview-131--savrlist.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant