feat: Allow specifying an Onion API host URL

This commit is contained in:
Jesse Wierzbinski 2024-06-25 18:53:44 -10:00
parent b2989e898e
commit 7b13265d47
No known key found for this signature in database
3 changed files with 10 additions and 0 deletions

View file

@ -75,6 +75,8 @@ services:
- lysand-net - lysand-net
environment: environment:
NUXT_PUBLIC_API_HOST: https://yourserver.com NUXT_PUBLIC_API_HOST: https://yourserver.com
# For Tor users, set the following environment variable in addition to the above
# NUXT_PUBLIC_ONION_API_HOST: http://youronionserver.onion
``` ```
Then, the frontend will be available at `http://localhost:3000` inside the container. To link it to a Lysand Server, set the `NUXT_PUBLIC_API_HOST` environment variable to the server's URL. Then, the frontend will be available at `http://localhost:3000` inside the container. To link it to a Lysand Server, set the `NUXT_PUBLIC_API_HOST` environment variable to the server's URL.

View file

@ -1,3 +1,10 @@
export const useBaseUrl = () => { export const useBaseUrl = () => {
// Check if running on Onion URL
if (useRequestURL().hostname.endsWith(".onion")) {
return ref(
useRuntimeConfig().public.onionApiHost ?? useRequestURL().origin,
);
}
return ref(useRuntimeConfig().public.apiHost ?? useRequestURL().origin); return ref(useRuntimeConfig().public.apiHost ?? useRequestURL().origin);
}; };

View file

@ -616,6 +616,7 @@ export default defineNuxtConfig({
siteName: "Lysand", siteName: "Lysand",
trailingSlash: true, trailingSlash: true,
apiHost: "https://social.lysand.org", apiHost: "https://social.lysand.org",
onionApiHost: undefined,
}, },
}, },
imports: { imports: {