From 14b4f28a1a739c12177c6ef0b20c9dea661fe459 Mon Sep 17 00:00:00 2001 From: reynoldsnlp Date: Sat, 31 Dec 2022 15:15:51 -0700 Subject: [PATCH] fix app.js with url_prefix --- libretranslate/app.py | 3 ++- libretranslate/static/js/app.js | 3 +-- libretranslate/templates/index.html | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libretranslate/app.py b/libretranslate/app.py index a468fe7..bd71404 100644 --- a/libretranslate/app.py +++ b/libretranslate/app.py @@ -283,7 +283,8 @@ def create_app(args): get_api_key_link=args.get_api_key_link, web_version=os.environ.get("LT_WEB") is not None, version=get_version(), - swagger_url=SWAGGER_URL + swagger_url=SWAGGER_URL, + url_prefix=args.url_prefix ) @bp.get("/javascript-licenses") diff --git a/libretranslate/static/js/app.js b/libretranslate/static/js/app.js index 3e9129d..6957b04 100644 --- a/libretranslate/static/js/app.js +++ b/libretranslate/static/js/app.js @@ -1,7 +1,6 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 // API host/endpoint -//var BaseUrl = window.location.protocol + "//" + window.location.host + window.location.pathname.length > 1 ? window.location.pathname : "" ; -var BaseUrl = window.location.href.slice(0, -1) +var BaseUrl = window.location.protocol + "//" + window.location.host + url_prefix ; var htmlRegex = /<(.*)>.*?|<(.*)\/>/; document.addEventListener('DOMContentLoaded', function(){ var sidenavElems = document.querySelectorAll('.sidenav'); diff --git a/libretranslate/templates/index.html b/libretranslate/templates/index.html index eafcc68..6061fd1 100644 --- a/libretranslate/templates/index.html +++ b/libretranslate/templates/index.html @@ -7,6 +7,9 @@ +