Skip to content

fix: apply custom headers by target origin, not hardcoded host#16

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/screenshot-header-origin-d662
Jul 22, 2026
Merged

fix: apply custom headers by target origin, not hardcoded host#16
cursor[bot] merged 2 commits into
mainfrom
cursor/screenshot-header-origin-d662

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Custom headers were only applied when the request URL started with hardcoded http://appwrite/. That breaks setups where _APP_WORKER_SCREENSHOTS_ROUTER is a different internal host (e.g. http://appwrite-api on k8s).

This replaces that prefix with the origin of the request URL, so headers follow whatever host is being captured while still staying off third-party subresources.

Changes

  • src/routes/screenshots.ts / src/routes/reports.ts: match against new URL(body.url).origin instead of http://appwrite/

Test plan

  • Screenshot against http://appwrite-api/?appwrite-preview=1 with custom headers — headers applied
  • Same page loading a third-party asset — headers not sent there
  • Default Compose host http://appwrite/ still works
Open in Web Open in Cursor 

Replace the hardcoded http://appwrite/ prefix check so screenshots and
reports inject custom headers for whatever origin is being captured.
This unblocks k8s setups where the router is appwrite-api (via
_APP_WORKER_SCREENSHOTS_ROUTER) while still keeping auth headers off
third-party subresources.

Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Docker Image Stats

Metric Value
Image Size 494MB
Memory Usage 156.1MiB
Cold Start Time 1.02s
Screenshot Time 4.10s

Screenshot benchmark: Average of 3 runs on https://appwrite.io

Replace the hardcoded http://appwrite/ prefix so headers follow the
screenshot/report URL origin (e.g. http://appwrite-api on k8s).

Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
@ChiragAgg5k
ChiragAgg5k marked this pull request as ready for review July 22, 2026 11:02
@cursor
cursor Bot merged commit 8e367c8 into main Jul 22, 2026
4 checks passed
@cursor
cursor Bot deleted the cursor/screenshot-header-origin-d662 branch July 22, 2026 11:02
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR applies custom headers according to the requested page’s origin. The main changes are:

  • Derive the allowed origin from body.url in report requests.
  • Use the same origin boundary for screenshot requests.
  • Keep custom headers off requests to other origins.

Confidence Score: 5/5

This looks safe to merge.

  • The target URL is validated before its origin is derived.
  • The trailing slash boundary prevents matching similarly prefixed hosts.
  • Redirects and subresources on other origins do not receive custom headers.
  • No blocking issues were found in the changed code.

Important Files Changed

Filename Overview
src/routes/reports.ts Replaces the hardcoded Appwrite host check with an origin derived from the requested report URL.
src/routes/screenshots.ts Applies screenshot headers only to requests matching the origin of the requested page.

Reviews (1): Last reviewed commit: "fix: apply custom headers by target orig..." | Re-trigger Greptile

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.

2 participants