feat: add werkzeug proxyfix to development server
This commit is contained in:
parent
7b7a574c5a
commit
87684e2647
2 changed files with 19 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import re
|
|||
from werkzeug.exceptions import HTTPException, NotFound
|
||||
from werkzeug.local import LocalManager
|
||||
from werkzeug.middleware.profiler import ProfilerMiddleware
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
from werkzeug.middleware.shared_data import SharedDataMiddleware
|
||||
from werkzeug.wrappers import Request, Response
|
||||
|
||||
|
|
@ -392,7 +393,13 @@ def sync_database(rollback: bool) -> bool:
|
|||
|
||||
|
||||
def serve(
|
||||
port=8000, profile=False, no_reload=False, no_threading=False, site=None, sites_path="."
|
||||
port=8000,
|
||||
profile=False,
|
||||
no_reload=False,
|
||||
no_threading=False,
|
||||
site=None,
|
||||
sites_path=".",
|
||||
proxy=False,
|
||||
):
|
||||
global application, _site, _sites_path
|
||||
_site = site
|
||||
|
|
@ -406,6 +413,9 @@ def serve(
|
|||
if not os.environ.get("NO_STATICS"):
|
||||
application = application_with_statics()
|
||||
|
||||
if proxy or os.environ.get("USE_PROXY"):
|
||||
application = ProxyFix(application, x_for=1, x_proto=1, x_host=1, x_port=1, x_prefix=1)
|
||||
|
||||
application.debug = True
|
||||
application.config = {"SERVER_NAME": "localhost:8000"}
|
||||
|
||||
|
|
|
|||
|
|
@ -923,6 +923,12 @@ def run_ui_tests(
|
|||
@click.command("serve")
|
||||
@click.option("--port", default=8000)
|
||||
@click.option("--profile", is_flag=True, default=False)
|
||||
@click.option(
|
||||
"--proxy",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="The development server may be run behind a proxy, e.g. ngrok / localtunnel",
|
||||
)
|
||||
@click.option("--noreload", "no_reload", is_flag=True, default=False)
|
||||
@click.option("--nothreading", "no_threading", is_flag=True, default=False)
|
||||
@click.option("--with-coverage", is_flag=True, default=False)
|
||||
|
|
@ -931,6 +937,7 @@ def serve(
|
|||
context,
|
||||
port=None,
|
||||
profile=False,
|
||||
proxy=False,
|
||||
no_reload=False,
|
||||
no_threading=False,
|
||||
sites_path=".",
|
||||
|
|
@ -952,6 +959,7 @@ def serve(
|
|||
frappe.app.serve(
|
||||
port=port,
|
||||
profile=profile,
|
||||
proxy=proxy,
|
||||
no_reload=no_reload,
|
||||
no_threading=no_threading,
|
||||
site=site,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue