Skip to content

fix(router): arelay.to is HTTPS only - #157

Merged
khaliqgant merged 2 commits into
mainfrom
fix/arelay-https
Oct 8, 2026
Merged

khaliqgant merged 2 commits into
mainfrom
fix/arelay-https

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Bug

http://arelay.to/agent-relay returned 200 over plain HTTP, and a chat POST to http://arelay.to/agent-relay/<id> was processed. Visitors' messages and our agent's replies could travel unencrypted. agentrelay.com already redirects (its zone's Always Use HTTPS setting); the arelay.to zone doesn't have it. Reported by the founder.

Fix (in the router, so it's in source control rather than a dashboard toggle)

getInsecureShortHostResponse runs first in fetch for arelay.to and www.arelay.to over http::

  • GET / HEAD → 301 to the same path and query on https:.
  • Any other method → 308 with location set and the plain-text body agent-relay: use HTTPS: https://…. Agents' curl doesn't follow redirects, so the agent sees the HTTPS URL in its output. The message is not processed or forwarded: a test asserts the upstream fetch is never called.
  • HTTPS, and every other host, are unchanged.

The snippet and guide already use https://, so this only affects someone typing http://.

Validation

Router: 109/109 tests (4 new) and typecheck clean. With #154, this router change deploys only after its commit's web deploy.

Follow-up (not in this PR)

Turning on Always Use HTTPS and HSTS on the arelay.to zone would also cover any path the router doesn't see. That's a production zone setting, so it's a human step.

🤖 Generated with Claude Code


Note

Medium Risk
Changes edge routing for a security-sensitive agent-chat entry host; behavior is narrow (HTTP-only on two hostnames) but blocks previously accepted plain-HTTP chat POSTs.

Overview
Enforces HTTPS for arelay.to and www.arelay.to in the router so agent chat and pages are no longer served or forwarded over plain HTTP (the short host’s zone lacks Cloudflare “Always Use HTTPS,” unlike agentrelay.com).

A new early gate, getInsecureShortHostResponse, runs at the start of fetch for http: requests to those hosts (including FQDN hosts with a trailing dot). GET/HEAD get a 301 to the same path and query on https:. All other methods (e.g. chat POST) get 308 with a Location header and a plain-text body agent-relay: use HTTPS: … so tools like curl that do not follow redirects still see the correct URL; those requests are not proxied upstream.

HTTPS traffic and other hostnames are unchanged. Tests cover redirects, 308 bodies, trailing-dot hosts, and an integration case that upstream fetch is never called for HTTP chat POSTs.

Reviewed by Cursor Bugbot for commit 74026a4. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Makes arelay.to HTTPS-only so agent chat messages and replies no longer travel unencrypted over plain HTTP. Trailing-dot hosts like arelay.to. are treated the same as arelay.to.

  • GET and HEAD requests to http://arelay.to get a permanent (301) redirect to the same HTTPS URL.
  • Other methods, such as chat POSTs, get a 308 whose body names the HTTPS URL so the agent's curl (which doesn't follow redirects) prints what to use; the message is never processed or forwarded.
  • HTTPS requests and all other hosts are unchanged; enabling the zone's Always Use HTTPS and HSTS settings is a separate follow-up.

Written for commit 74026a4. Summary will update on new commits.

View guided diff Turn on auto-fix


Agent Relay sessions

  • claude session 1e2adfbe · opened via gh pr create · last active 2026-10-08
  • claude session a4302a83 · contributor · ran gh pr commands · last active 2026-10-08

http://arelay.to served pages and accepted chat messages over plain HTTP.
GET/HEAD now redirect permanently to HTTPS; other methods get a 308 whose
body names the HTTPS URL (curl does not follow redirects, so the agent
sees what to use) and the message is never processed or forwarded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef6019d4-68f5-4e61-8d41-04f0a962e68e
📥 Commits

Reviewing files that changed from the base of the PR and between 1d537a6 and 74026a4.

📒 Files selected for processing (2)
  • router/index.ts
  • router/test/agent-chat.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T02:51:22.336145Z 8fec277 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="router/index.ts">

<violation number="1" location="router/index.ts:518">
P3: A trailing-dot FQDN in the Host header (`http://arelay.to./…`) bypasses this HTTPS-only gate because `url.hostname` keeps the trailing dot (`"arelay.to."`), which matches neither `SHORT_HOST` nor `SHORT_HOST_WWW`. Normalize the hostname (strip a trailing `.`) before comparing so every form of the short host gets the same HTTPS-only treatment.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread router/index.ts
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed!

Environment URL
Web https://96091731-agentrelay-web.agent-workforce.workers.dev

This is a Cloudflare Workers preview version of this PR's build.

…S gate

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@khaliqgant

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@khaliqgant
khaliqgant merged commit d019fb8 into main Oct 8, 2026
5 checks passed
@khaliqgant
khaliqgant deleted the fix/arelay-https branch October 8, 2026 03:15
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