mirror of
https://github.com/Sudo-JHare/FHIRFLARE-IG-Toolkit.git
synced 2025-06-15 00:40:00 +00:00
Dynamic Hostname fix
Patch for dynamic host names
This commit is contained in:
parent
5efae0c64e
commit
179982dedc
8
app.py
8
app.py
@ -55,6 +55,8 @@ app.config['API_KEY'] = os.environ.get('API_KEY', 'your-fallback-api-key-here')
|
|||||||
app.config['VALIDATE_IMPOSED_PROFILES'] = True
|
app.config['VALIDATE_IMPOSED_PROFILES'] = True
|
||||||
app.config['DISPLAY_PROFILE_RELATIONSHIPS'] = True
|
app.config['DISPLAY_PROFILE_RELATIONSHIPS'] = True
|
||||||
app.config['UPLOAD_FOLDER'] = '/app/static/uploads' # For GoFSH output
|
app.config['UPLOAD_FOLDER'] = '/app/static/uploads' # For GoFSH output
|
||||||
|
app.config['APP_BASE_URL'] = os.environ.get('APP_BASE_URL', 'http://localhost:5000')
|
||||||
|
app.config['HAPI_FHIR_URL'] = os.environ.get('HAPI_FHIR_URL', 'http://localhost:8080/fhir')
|
||||||
CONFIG_PATH = '/usr/local/tomcat/conf/application.yaml'
|
CONFIG_PATH = '/usr/local/tomcat/conf/application.yaml'
|
||||||
|
|
||||||
# Register blueprints immediately after app setup
|
# Register blueprints immediately after app setup
|
||||||
@ -1317,10 +1319,10 @@ def proxy_hapi(subpath):
|
|||||||
logger.info(f"Proxy target identified from header: {final_base_url}")
|
logger.info(f"Proxy target identified from header: {final_base_url}")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logger.warning(f"Invalid URL in X-Target-FHIR-Server header: '{target_server_header}'. Falling back. Error: {e}")
|
logger.warning(f"Invalid URL in X-Target-FHIR-Server header: '{target_server_header}'. Falling back. Error: {e}")
|
||||||
final_base_url = "http://localhost:8080/fhir"
|
final_base_url = current_app.config['HAPI_FHIR_URL'].rstrip('/')
|
||||||
logger.debug(f"Falling back to default local HAPI due to invalid header: {final_base_url}")
|
logger.debug(f"Falling back to default local HAPI due to invalid header: {final_base_url}")
|
||||||
else:
|
else:
|
||||||
final_base_url = "http://localhost:8080/fhir"
|
final_base_url = current_app.config['HAPI_FHIR_URL'].rstrip('/')
|
||||||
logger.debug(f"No target header found, proxying to default local HAPI: {final_base_url}")
|
logger.debug(f"No target header found, proxying to default local HAPI: {final_base_url}")
|
||||||
|
|
||||||
# Construct the final URL for the target server request
|
# Construct the final URL for the target server request
|
||||||
@ -1424,7 +1426,7 @@ def load_ig_to_hapi():
|
|||||||
resource_id = resource.get('id')
|
resource_id = resource.get('id')
|
||||||
if resource_type and resource_id:
|
if resource_type and resource_id:
|
||||||
response = requests.put(
|
response = requests.put(
|
||||||
f"http://localhost:8080/fhir/{resource_type}/{resource_id}",
|
f"{current_app.config['HAPI_FHIR_URL'].rstrip('/')}/{resource_type}/{resource_id}",
|
||||||
json=resource,
|
json=resource,
|
||||||
headers={'Content-Type': 'application/fhir+json'}
|
headers={'Content-Type': 'application/fhir+json'}
|
||||||
)
|
)
|
||||||
|
@ -16,5 +16,7 @@ services:
|
|||||||
- FLASK_APP=app.py
|
- FLASK_APP=app.py
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=development
|
||||||
- NODE_PATH=/usr/lib/node_modules
|
- NODE_PATH=/usr/lib/node_modules
|
||||||
- APP_MODE=lite
|
- APP_MODE=lite
|
||||||
|
- APP_BASE_URL=https://yourdomain.com
|
||||||
|
- HAPI_FHIR_URL=https://hapi.yourdomain.com/fhir
|
||||||
command: supervisord -c /etc/supervisord.conf
|
command: supervisord -c /etc/supervisord.conf
|
||||||
|
@ -1616,7 +1616,7 @@ def validate_resource_against_profile(package_name, version, resource, include_d
|
|||||||
# Attempt HAPI validation if a profile is specified
|
# Attempt HAPI validation if a profile is specified
|
||||||
if result['profile']:
|
if result['profile']:
|
||||||
try:
|
try:
|
||||||
hapi_url = f"http://localhost:8080/fhir/{resource['resourceType']}/$validate?profile={result['profile']}"
|
hapi_url = f"{current_app.config['HAPI_FHIR_URL'].rstrip('/')}/{resource['resourceType']}/$validate?profile={result['profile']}"
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
hapi_url,
|
hapi_url,
|
||||||
json=resource,
|
json=resource,
|
||||||
@ -3766,7 +3766,7 @@ def retrieve_bundles(fhir_server_url, resources, output_zip, validate_references
|
|||||||
|
|
||||||
|
|
||||||
# --- Determine Base URL and Headers for Proxy ---
|
# --- Determine Base URL and Headers for Proxy ---
|
||||||
base_proxy_url = 'http://localhost:5000/fhir' # Always target the proxy endpoint
|
base_proxy_url = f"{current_app.config['APP_BASE_URL'].rstrip('/')}/fhir"
|
||||||
headers = {'Accept': 'application/fhir+json, application/fhir+xml;q=0.9, */*;q=0.8'}
|
headers = {'Accept': 'application/fhir+json, application/fhir+xml;q=0.9, */*;q=0.8'}
|
||||||
is_custom_url = fhir_server_url != '/fhir' and fhir_server_url is not None and fhir_server_url.startswith('http')
|
is_custom_url = fhir_server_url != '/fhir' and fhir_server_url is not None and fhir_server_url.startswith('http')
|
||||||
if is_custom_url:
|
if is_custom_url:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user