Skip to content

fix: return descriptive error for relative URLs without Referer header#137

Merged
mms-gianni merged 3 commits into
everywall:release/v0.0.24from
aayushprsingh:fix/extract-url-missing-referer
May 14, 2026
Merged

fix: return descriptive error for relative URLs without Referer header#137
mms-gianni merged 3 commits into
everywall:release/v0.0.24from
aayushprsingh:fix/extract-url-missing-referer

Conversation

@aayushprsingh
Copy link
Copy Markdown

Summary

When a relative URL path is requested without a Referer header (e.g. issue #75 where a Cloudflare challenge redirect produces /cdn-cgi/challenge-platform/...), the Go HTTP client returns a confusing http: no Host in request URL error with no context.

This fix adds two explicit validation checks in extractUrl:

  1. No Referer header → returns a descriptive error explaining the request needs a Referer header to resolve the relative URL, with a suggestion to use the form or navigate to a full URL first.
  2. Malformed Referer (relative path, no scheme/host) → returns a clear error explaining the referer cannot be used to reconstruct the target URL.

This directly addresses the root cause of issue #75, where the error http: no Host in request URL masked that the real problem was the missing Referer header needed to resolve the relative CDN challenge path.

Changes

handlers/proxy.goextractUrl()

  • Added early guard: if relative URL and no Referer header → descriptive error
  • Changed URL reconstruction to use refererUrl.Scheme/Host directly (was incorrectly using realUrl from a path-stripped parse of referer)
  • Added guard for referer with empty host

handlers/proxy.test.go

  • TestProxySiteRelativeUrlWithoutReferer — asserts 500 + body contains "Referer" hint when no Referer is provided
  • TestProxySiteRelativeUrlWithRefererMissingHost — asserts 500 + helpful error when Referer is a relative path

Verification

Go is not installed in this environment. Logic was verified via manual code review and diff inspection. Tests require go test ./handlers/... to be run by the maintainer or CI.

Fixes #75

dependabot Bot and others added 3 commits April 24, 2026 22:16
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 6.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@v4...v6)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ions/dot-github/workflows/docker/metadata-action-6

Bump docker/metadata-action from 4 to 6 in /.github/workflows
When a relative URL is requested without a Referer header, the Go
HTTP client would return a confusing 'http: no Host in request URL'
error. Now a descriptive error is returned explaining the root cause
and how to fix it.

Similarly, if a referer header lacks a scheme/host (e.g. a relative
path), a clear error is returned instead of silently producing an
empty host URL.

Fixes everywall#75
Copy link
Copy Markdown
Contributor

@mms-gianni mms-gianni left a comment

Choose a reason for hiding this comment

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

LGTM

@mms-gianni mms-gianni changed the base branch from main to release/v0.0.24 May 9, 2026 16:09
@mms-gianni mms-gianni added this to the v0.0.24 milestone May 9, 2026
@mms-gianni mms-gianni merged commit b4e531d into everywall:release/v0.0.24 May 14, 2026
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.

http: no Host in request URL

2 participants