Skip to content

Commit d315d5b

Browse files
committed
fix: Add ProxyFix to serve swagger.json over HTTPs
1 parent 699d5bb commit d315d5b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

time_tracker_api/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def init_app(app: Flask):
4646
app.logger.setLevel(logging.INFO)
4747
add_debug_toolbar(app)
4848

49+
add_werkzeug_proxy_fix(app)
50+
4951
cors_origins = app.config.get('CORS_ORIGINS')
5052
if cors_origins:
5153
enable_cors(app, cors_origins)
@@ -74,3 +76,9 @@ def enable_cors(app: Flask, cors_origins: str):
7476
cors_origins_list = cors_origins.split(",")
7577
CORS(app, resources={r"/*": {"origins": cors_origins_list}})
7678
app.logger.info("Set CORS access to [%s]" % cors_origins)
79+
80+
81+
def add_werkzeug_proxy_fix(app: Flask):
82+
from werkzeug.middleware.proxy_fix import ProxyFix
83+
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
84+
app.logger.info("Add ProxyFix to serve swagger.json over https.")

0 commit comments

Comments
 (0)