forked from open-webui/open-webui
feat: backend required error page
This commit is contained in:
parent
540b50e176
commit
8d5c3ee56f
3 changed files with 62 additions and 13 deletions
|
@ -31,13 +31,13 @@ if ENV == "prod":
|
||||||
# WEBUI_VERSION
|
# WEBUI_VERSION
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
WEBUI_VERSION = os.environ.get("WEBUI_VERSION", "v1.0.0-alpha.40")
|
WEBUI_VERSION = os.environ.get("WEBUI_VERSION", "v1.0.0-alpha.42")
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# WEBUI_AUTH
|
# WEBUI_AUTH (Required for security)
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
WEBUI_AUTH = True if os.environ.get("WEBUI_AUTH", "FALSE") == "TRUE" else False
|
WEBUI_AUTH = True
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# WEBUI_JWT_SECRET_KEY
|
# WEBUI_JWT_SECRET_KEY
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const resBackend = await fetch(`${WEBUI_API_BASE_URL}/`, {
|
// Check Backend Status
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
@ -26,13 +27,14 @@
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(resBackend);
|
if (res) {
|
||||||
await config.set(resBackend);
|
await config.set(res);
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
if ($config) {
|
if ($config) {
|
||||||
if ($config.auth) {
|
|
||||||
if (localStorage.token) {
|
if (localStorage.token) {
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/auths`, {
|
// Get Session User Info
|
||||||
|
const sessionUser = await fetch(`${WEBUI_API_BASE_URL}/auths`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -49,8 +51,8 @@
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (sessionUser) {
|
||||||
await user.set(res);
|
await user.set(sessionUser);
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
await goto('/auth');
|
await goto('/auth');
|
||||||
|
@ -59,6 +61,8 @@
|
||||||
await goto('/auth');
|
await goto('/auth');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await goto(`/error`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
|
@ -69,8 +73,9 @@
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Ollama</title>
|
<title>Ollama</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
<Toaster />
|
|
||||||
|
|
||||||
{#if $config !== undefined && loaded}
|
{#if loaded}
|
||||||
<slot />
|
<slot />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<Toaster />
|
||||||
|
|
44
src/routes/error/+page.svelte
Normal file
44
src/routes/error/+page.svelte
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<script>
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { config } from '$lib/stores';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
if ($config) {
|
||||||
|
await goto('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if loaded}
|
||||||
|
<div class="absolute w-full h-full flex z-50">
|
||||||
|
<div class="absolute rounded-xl w-full h-full backdrop-blur bg-gray-900/5 flex justify-center">
|
||||||
|
<div class="m-auto pb-44 flex flex-col justify-center">
|
||||||
|
<div class="max-w-md">
|
||||||
|
<div class="text-center text-2xl font-medium z-50">Ollama WebUI Backend Required</div>
|
||||||
|
|
||||||
|
<div class=" mt-4 text-center text-sm w-full">
|
||||||
|
Oops! It seems like your Ollama WebUI needs a little attention. <br
|
||||||
|
class=" hidden sm:flex"
|
||||||
|
/>
|
||||||
|
describe troubleshooting/installation, help @ discord
|
||||||
|
|
||||||
|
<!-- TODO: update text -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" mt-6 mx-auto relative group w-fit">
|
||||||
|
<button
|
||||||
|
class="relative z-20 flex px-5 py-2 rounded-full bg-gray-100 hover:bg-gray-200 transition font-medium text-sm"
|
||||||
|
>
|
||||||
|
Check Again
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
Loading…
Reference in a new issue