Skip to content

Commit

Permalink
Fixes for self-hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and AnthonyRonning committed Sep 29, 2023
1 parent 9caa912 commit 27aee22
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
*.md
dist
justfile
.env.local
2 changes: 1 addition & 1 deletion .github/workflows/android-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
VITE_RGS: https://scorer.mutinywallet.com/v1/rgs/snapshot/
VITE_AUTH: https://auth.mutinywallet.com
VITE_SUBSCRIPTIONS: https://subscriptions.mutinywallet.com
VITE_STORAGE: https://storage.mutinywallet.com
VITE_STORAGE: https://storage.mutinywallet.com/v2
VITE_FEEDBACK: https://feedback.mutinywallet.com
VITE_SCORER: https://scorer.mutinywallet.com
VITE_PRIMAL: https://primal-cache.mutinywallet.com/api
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ RUN apt update && apt install -y git

# Add the ARG directives for build-time environment variables
ARG VITE_NETWORK="bitcoin"
ARG VITE_PROXY="wss://p.mutinywallet.com"
ARG VITE_ESPLORA="https://mutinynet.com/api"
ARG VITE_PROXY="/_services/proxy"
ARG VITE_ESPLORA
ARG VITE_LSP="https://lsp.voltageapi.com"
ARG VITE_RGS="https://rgs.mutinynet.com/snapshot/"
ARG VITE_RGS
ARG VITE_AUTH
ARG VITE_STORAGE
ARG VITE_STORAGE="/_services/vss/v2"
ARG VITE_SELFHOSTED="true"

# Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@kobalte/tailwindcss": "^0.5.0",
"@modular-forms/solid": "^0.18.1",
"@mutinywallet/barcode-scanner": "5.0.0-beta.3",
"@mutinywallet/mutiny-wasm": "0.4.19",
"@mutinywallet/mutiny-wasm": "0.4.20",
"@mutinywallet/waila-wasm": "^0.2.1",
"@nostr-dev-kit/ndk": "^0.8.11",
"@solid-primitives/upload": "^0.0.111",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions src/logic/mutinyWalletSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,27 @@ export async function getSettings() {

// Expect urls like /_services/proxy and /_services/storage
if (selfhosted) {
const base = window.location.origin;
let base = window.location.origin;
console.log("Self-hosted mode enabled, using base URL", base);
const proxy = settings.proxy;
const storage = settings.storage;
if (proxy && proxy.startsWith("/")) {
settings.proxy = base + proxy;
}
if (storage && storage.startsWith("/")) {
settings.storage = base + storage;
}

const proxy = settings.proxy;
if (proxy && proxy.startsWith("/")) {
if (base.startsWith("http://")) {
base = base.replace("http://", "ws://");
} else if (base.startsWith("https://")) {
base = base.replace("https://", "wss://");
}
settings.proxy = base + proxy;
}
}

if (!settings.network || !settings.proxy || !settings.esplora) {
if (!settings.network || !settings.proxy) {
throw new Error(
"Missing a default setting for network, proxy, or esplora. Check your .env file to make sure it looks like .env.sample"
"Missing a default setting for network or proxy. Check your .env file to make sure it looks like .env.sample"
);
}

Expand Down

0 comments on commit 27aee22

Please sign in to comment.