diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml
index 072e77354..3ca994084 100644
--- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml
+++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml
@@ -6,10 +6,6 @@
@section HeadScripts {
-
-
}
diff --git a/BTCPayServer/wwwroot/modal/btcpay.js b/BTCPayServer/wwwroot/modal/btcpay.js
index 557b7c80d..dd0f0675e 100644
--- a/BTCPayServer/wwwroot/modal/btcpay.js
+++ b/BTCPayServer/wwwroot/modal/btcpay.js
@@ -1,5 +1,19 @@
/* jshint browser: true, strict: false, maxlen: false, maxstatements: false */
(function () {
+ var supportsCurrentScript = ("currentScript" in document);
+ var thisScript = "";
+ if (supportsCurrentScript) {
+ thisScript = document.currentScript.src;
+ }
+ else {
+ for (var i = 0; i < document.scripts.length; i++) {
+ var script = document.scripts[i];
+ if (script.src.endsWith("btcpay.js")) {
+ thisScript = script.src;
+ }
+ }
+ }
+
function warn() {
if (window.console && window.console.warn) {
window.console.warn.apply(window.console, arguments);
@@ -25,6 +39,10 @@
iframe.style.zIndex = '2000';
var origin = 'http://slack.btcpayserver.org join us there, and initialize this with your origin url through setApiUrlPrefix';
+ if (thisScript.endsWith("/modal/btcpay.js")) {
+ // We can't just take the domain as btcpay can run under a sub path with RootPath
+ origin = thisScript.substr(0, thisScript.length - "/modal/btcpay.js".length);
+ }
// urlPrefix should be site root without trailing slash
function setApiUrlPrefix(urlPrefix) {
origin = stripTrailingSlashes(urlPrefix);