diff --git a/.gitea/workflows/build-app.yml b/.gitea/workflows/build-app.yml index 5afced6..49504f8 100644 --- a/.gitea/workflows/build-app.yml +++ b/.gitea/workflows/build-app.yml @@ -26,14 +26,10 @@ jobs: - name: Build image run: | cd app - docker build --build-arg WEBSITE_REPORT_URL=https://git.ngn.tf/ngn/website/issues/new \ - --build-arg WEBSITE_SOURCE_URL=https://git.ngn.tf/ngn/website \ - --build-arg WEBSITE_APP_URL_CLEAR=https://ngn.tf \ - --build-arg WEBSITE_APP_URL_ONION=http://ngntfwmwovvku6eqi7dzzgzv2wzlvq2cqtqha7ccgzub2xnivsuxnuyd.onion \ - --build-arg WEBSITE_APP_URL_I2P=http://ngn.i2p \ - --build-arg WEBSITE_API_URL_CLEAR=https://api.ngn.tf \ - --build-arg WEBSITE_API_URL_ONION=http://api.ngntfwmwovvku6eqi7dzzgzv2wzlvq2cqtqha7ccgzub2xnivsuxnuyd.onion \ - --build-arg WEBSITE_API_URL_I2P=https://api.ngn.i2p \ - --build-arg WEBSITE_DOC_URL=http://doc:7003 \ + docker build --build-arg WEBSITE_REPORT_URL=https://git.ngn.tf/ngn/website/issues/new \ + --build-arg WEBSITE_SOURCE_URL=https://git.ngn.tf/ngn/website \ + --build-arg WEBSITE_DOC_URL=http://doc:7003 \ + --build-arg WEBSITE_API_URL=https://api:7002 \ + --build-arg WEBSITE_API_PATH=/api \ --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest . docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest diff --git a/api/config/config.go b/api/config/config.go index 1a83c4d..5319703 100644 --- a/api/config/config.go +++ b/api/config/config.go @@ -37,14 +37,14 @@ func (c *Type) Load() (err error) { // default options c.Options = []Option{ - {Name: "debug", Value: "false", Type: OPTION_TYPE_BOOL, Required: true}, // should display debug messgaes? - {Name: "app_url_clear", Value: "http://localhost:7001/", Type: OPTION_TYPE_URL, Required: true}, // frontend application URL for the website - {Name: "password", Value: "", Type: OPTION_TYPE_STR, Required: true}, // admin password - {Name: "host", Value: "0.0.0.0:7002", Type: OPTION_TYPE_STR, Required: true}, // host the server should listen on - {Name: "ip_header", Value: "X-Real-IP", Type: OPTION_TYPE_STR, Required: false}, // header that should be checked for obtaining the client IP - {Name: "interval", Value: "1h", Type: OPTION_TYPE_STR, Required: false}, // service status check interval - {Name: "timeout", Value: "15s", Type: OPTION_TYPE_STR, Required: false}, // timeout for the service status check - {Name: "limit", Value: "5s", Type: OPTION_TYPE_STR, Required: false}, // if the service responds slower than this limit, it will be marked as "slow" + {Name: "debug", Value: "false", Type: OPTION_TYPE_BOOL, Required: true}, // should display debug messgaes? + {Name: "app_url", Value: "http://localhost:7001/", Type: OPTION_TYPE_URL, Required: true}, // frontend application URL for the website + {Name: "password", Value: "", Type: OPTION_TYPE_STR, Required: true}, // admin password + {Name: "host", Value: "0.0.0.0:7002", Type: OPTION_TYPE_STR, Required: true}, // host the server should listen on + {Name: "ip_header", Value: "X-Real-IP", Type: OPTION_TYPE_STR, Required: false}, // header that should be checked for obtaining the client IP + {Name: "interval", Value: "1h", Type: OPTION_TYPE_STR, Required: false}, // service status check interval + {Name: "timeout", Value: "15s", Type: OPTION_TYPE_STR, Required: false}, // timeout for the service status check + {Name: "limit", Value: "5s", Type: OPTION_TYPE_STR, Required: false}, // if the service responds slower than this limit, it will be marked as "slow" } c.Count = len(c.Options) diff --git a/app/Dockerfile b/app/Dockerfile index 329b8d8..9037258 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,32 +1,17 @@ # build the application with node FROM node:23.11.0 AS build -# app URLs -ARG WEBSITE_APP_URL_CLEAR -ARG WEBSITE_APP_URL_ONION -ARG WEBSITE_APP_URL_I2P - -ENV WEBSITE_APP_URL_CLEAR=$WEBSITE_APP_URL_CLEAR -ENV WEBSITE_APP_URL_ONION=$WEBSITE_APP_URL_ONION -ENV WEBSITE_APP_URL_I2P=$WEBSITE_APP_URL_I2P - -# API URLs -ARG WEBSITE_API_URL_CLEAR -ARG WEBSITE_API_URL_ONION -ARG WEBSITE_API_URL_I2P - -ENV WEBSITE_API_URL_CLEAR=$WEBSITE_API_URL_CLEAR -ENV WEBSITE_API_URL_ONION=$WEBSITE_API_URL_ONION -ENV WEBSITE_API_URL_I2P=$WEBSITE_API_URL_I2P - -# other config ARG WEBSITE_REPORT_URL ARG WEBSITE_SOURCE_URL ARG WEBSITE_DOC_URL +ARG WEBSITE_API_URL +ARG WEBSITE_API_PATH ENV WEBSITE_REPORT_URL=$WEBSITE_REPORT_URL ENV WEBSITE_SOURCE_URL=$WEBSITE_SOURCE_URL ENV WEBSITE_DOC_URL=$WEBSITE_DOC_URL +ENV WEBSITE_API_URL=$WEBSITE_API_URL +ENV WEBSITE_API_PATH=$WEBSITE_API_PATH WORKDIR /app COPY . /app diff --git a/app/src/lib/api.js b/app/src/lib/api.js index 402796e..9c0e8c5 100644 --- a/app/src/lib/api.js +++ b/app/src/lib/api.js @@ -1,9 +1,14 @@ -import { urljoin, env_url } from "$lib/util.js"; +import { browser } from "$app/environment"; +import { urljoin } from "$lib/util.js"; const api_version = "v1"; function api_urljoin(path = null, query = {}) { - let api_url = urljoin(env_url("API"), api_version); + let api_url = ""; + + if (browser) api_url = urljoin(import.meta.env.WEBSITE_API_PATH, api_version); + else api_url = urljoin(import.meta.env.WEBSITE_API_URL, api_version); + return urljoin(api_url, path, query); } diff --git a/app/src/lib/doc.js b/app/src/lib/doc.js index b1e09e1..c7dc91b 100644 --- a/app/src/lib/doc.js +++ b/app/src/lib/doc.js @@ -1,4 +1,4 @@ -import { urljoin, env_url } from "$lib/util.js"; +import { urljoin } from "$lib/util.js"; function doc_urljoin(path = null, query = {}) { return urljoin(import.meta.env.WEBSITE_DOC_URL, path, query); diff --git a/app/src/lib/footer.svelte b/app/src/lib/footer.svelte index 26166da..b014eb6 100644 --- a/app/src/lib/footer.svelte +++ b/app/src/lib/footer.svelte @@ -1,14 +1,16 @@ @@ -20,24 +22,28 @@ / - {$_("footer.license")} + {$_("footer.license")} / - {$_("footer.privacy")} + {$_("footer.privacy")} - - {$_("footer.number", { - values: { - total: data.total, - since: date_from_ts(data.since), - }, - })} - {#if data.number % 1000 == 0} - ({$_("footer.wow")}) - {/if} - + {#if show_counter} + + {$_("footer.number", { + values: { + total: data.total, + since: date_from_ts(data.since), + }, + })} + {#if data.number % 1000 == 0} + ({$_("footer.wow")}) + {/if} + + {:else} + {$_("footer.js")} + {/if}