refactor: move single instance config to runtime (#1664)

pull/1672/head
Daniel Roe 2023-02-07 04:10:43 -08:00 zatwierdzone przez GitHub
rodzic 9e09c9072f
commit 2128d11238
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
NUXT_PUBLIC_TRANSLATE_API=
NUXT_PUBLIC_DEFAULT_SERVER=
SINGLE_INSTANCE_SERVER=
NUXT_PUBLIC_SINGLE_INSTANCE=
NUXT_PUBLIC_PRIVACY_POLICY_URL=
# Production only

Wyświetl plik

@ -1,7 +1,7 @@
import type { Ref } from 'vue'
export const useSignIn = (input?: Ref<HTMLInputElement | undefined>) => {
const singleInstanceServer = useAppConfig().singleInstanceServer
const singleInstanceServer = useRuntimeConfig().public.singleInstance
const userSettings = useUserSettings()
const users = useUsers()
const { t } = useI18n()

Wyświetl plik

@ -45,7 +45,7 @@ There are 5 environment variables to add.
| NUXT_CLOUDFLARE_NAMESPACE_ID | This is your CloudFlare KV Namespace ID. You can find it in "Workers > KV". |
| NUXT_STORAGE_DRIVER | Because we're using CloudFlare, we'll need to set this to `cloudflare`. |
| NUXT_PUBLIC_DEFAULT_SERVER | This is the address of the Mastodon instance that will show up when a user visits your Elk deployment and is not logged in. If you don't make that variable, it will point to `m.webtoo.ls` by default. |
| SINGLE_INSTANCE_SERVER | This can't be set at runtime, but if enabled at build-time it will disable signing in to servers other than the server specified in `NUXT_PUBLIC_DEFAULT_SERVER` |
| NUXT_PUBLIC_SINGLE_INSTANCE | If enabled it will disable signing in to servers other than the server specified in `NUXT_PUBLIC_DEFAULT_SERVER` |
| NUXT_PUBLIC_PRIVACY_POLICY_URL | This is the URL to a web page with information on your privacy policy. |
That's it! All that's left to do is...

Wyświetl plik

@ -24,7 +24,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
return
// Handle redirecting to new permalink structure for users with old links
if (!useAppConfig().singleInstanceServer && !to.params.server) {
if (!useRuntimeConfig().public.singleInstance && !to.params.server) {
return {
...to,
params: {

Wyświetl plik

@ -1,5 +1,5 @@
export default defineNuxtRouteMiddleware(async (to) => {
if (process.server || !useAppConfig().singleInstanceServer)
if (process.server || !useRuntimeConfig().public.singleInstance)
return
if (to.params.server) {

Wyświetl plik

@ -96,7 +96,6 @@ export default defineNuxtConfig({
},
},
appConfig: {
singleInstanceServer: process.env.SINGLE_INSTANCE_SERVER === 'true',
storage: {
driver: process.env.NUXT_STORAGE_DRIVER ?? (isCI ? 'cloudflare' : 'fs'),
},
@ -115,6 +114,7 @@ export default defineNuxtConfig({
translateApi: '',
// Use the instance where Elk has its Mastodon account as the default
defaultServer: 'm.webtoo.ls',
singleInstance: false,
},
storage: {
fsBase: 'node_modules/.cache/app',