Skip to content

Conversation

@Ulthran
Copy link
Contributor

@Ulthran Ulthran commented Jan 30, 2026

Motivation

  • Enable running the app locally for development while also allowing deployment behind a reverse proxy that exposes the app at a URL prefix.
  • Provide a simple configuration via an environment variable so deployment manifests (e.g. podman/docker/k8s) can control the mounted prefix without changing code.

Description

  • Add a _normalize_url_prefix helper that normalizes SAMPLE_REGISTRY_URL_PREFIX and returns a cleaned prefix string.
  • When SAMPLE_REGISTRY_URL_PREFIX is set, mount the Flask app at that prefix using werkzeug.middleware.dispatcher.DispatcherMiddleware and expose the WSGI entrypoint as sample_registry.app:application, otherwise keep application = app for direct development runs.
  • Preserve existing ProxyFix usage and read-only SQLite configuration; update imports and documentation by adding DispatcherMiddleware and documenting SAMPLE_REGISTRY_URL_PREFIX in README.md.

Testing

  • No automated tests were executed for this change.

Codex Task

Copilot AI review requested due to automatic review settings January 30, 2026 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for mounting the Flask application under a configurable URL prefix so it can run behind a reverse proxy while preserving the existing local development workflow and read-only SQLite behavior.

Changes:

  • Introduced _normalize_url_prefix and URL_PREFIX handling in sample_registry/app.py, wiring DispatcherMiddleware to expose a WSGI entrypoint sample_registry.app:application that mounts the app at SAMPLE_REGISTRY_URL_PREFIX when set.
  • Kept ProxyFix and read-only SQLite configuration intact while ensuring application falls back to the bare app in non-prefixed (local dev) setups.
  • Updated README.md to document SAMPLE_REGISTRY_URL_PREFIX and the sample_registry.app:application WSGI entrypoint for proxy deployments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sample_registry/app.py Adds URL prefix normalization, configures DispatcherMiddleware to mount the Flask app under an optional SAMPLE_REGISTRY_URL_PREFIX, and exposes application as the WSGI entrypoint while preserving ProxyFix and the existing dev app.run path.
README.md Documents how to configure SAMPLE_REGISTRY_URL_PREFIX and use sample_registry.app:application when deploying behind a reverse proxy at a URL prefix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +49
def _normalize_url_prefix(raw_prefix: str) -> str:
prefix = (raw_prefix or "").strip()
if not prefix or prefix == "/":
return ""
if not prefix.startswith("/"):
prefix = f"/{prefix}"
return prefix.rstrip("/")
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

_normalize_url_prefix is annotated to accept str, but it is immediately used with os.getenv("SAMPLE_REGISTRY_URL_PREFIX"), which can return None; this mismatched type annotation can cause static type checkers (e.g., mypy) to flag an error and makes the intended contract less clear. Consider updating the parameter type to Optional[str] (and importing it if needed) so the signature accurately reflects the possible inputs.

Copilot uses AI. Check for mistakes.
@Ulthran Ulthran closed this Jan 30, 2026
@Ulthran Ulthran deleted the codex/update-app-for-dev-and-prod-deployment branch January 30, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants