Skip to content

Commit

Permalink
redirect to custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
redraw committed Apr 24, 2024
1 parent 9d947cb commit 78fa0b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import json
import logging
from datetime import timedelta

from flask import Flask, Response, request, jsonify
from flask import Flask, Response, request, jsonify, redirect
from flask_cors import CORS
from flask_swagger_ui import get_swaggerui_blueprint
from marshmallow import ValidationError
Expand All @@ -19,6 +20,17 @@
CORS(api)


@api.before_request
def redirect_to_custom_domain():
custom_domain = os.getenv('CUSTOM_DOMAIN')
if (
custom_domain and
"FLY_APP_NAME" in os.environ and
request.host == f"{os.getenv('FLY_APP_NAME')}.fly.dev"
):
return redirect(f'https://{custom_domain}', code=301)


@api.route('/passes/<int:norad_id>')
def passes(norad_id):
try:
Expand Down

0 comments on commit 78fa0b1

Please sign in to comment.