Skip to content

feat: Add --forward option to proxy requests to external servers#11

Open
theVAX wants to merge 1 commit into
viur-framework:mainfrom
theVAX:feature/forward-proxy
Open

feat: Add --forward option to proxy requests to external servers#11
theVAX wants to merge 1 commit into
viur-framework:mainfrom
theVAX:feature/forward-proxy

Conversation

@theVAX
Copy link
Copy Markdown
Member

@theVAX theVAX commented Feb 23, 2026

Summary

  • Adds a new --forward PATTERN=URL CLI argument (repeatable) that forwards matching requests to an external server
  • New ForwardProxy WSGI middleware with chunk-based streaming (memory-safe for large files)
  • Forward rules are registered in the Dispatcher before the gunicorn proxy, so they take priority for matching patterns
  • Non-matching requests and errors fall through to the local app — no regression

Use case

During local development, files uploaded to production (Google Cloud Storage) aren't available in the local Datastore emulator. This option transparently proxies those requests to the production server:

app_server -A my-app \
    --forward '/file/.*=https://my-app.appspot.com' \
    deploy/

Test plan

  • Tested with a real ViUR project (verwischte-tinte): /file/download/... returns 200 OK with correct content-type
  • Non-forwarded routes (/json/..., static files) still work as before
  • Without --forward: behavior unchanged (no regression)
  • Review: streaming works for large files (>4 GB) without memory issues

Allows forwarding matching requests (by regex pattern) to an external
URL during local development. Useful for proxying file downloads to
a production server when resources don't exist in the local emulator.

Responses are streamed chunk-wise so large files don't consume memory.

Usage: app_server --forward '/file/.*=https://my-app.appspot.com' ...
@ArneGudermann ArneGudermann self-requested a review February 27, 2026 12:00
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