allow external URLs in private instances

This commit is contained in:
Christian Beutel
2025-07-10 15:29:07 +02:00
parent d6e08e6d80
commit 68f36dbf0c
3 changed files with 15 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import { browser } from "$app/environment";
import { env } from "$env/dynamic/public";
const privateRoutes = [
@@ -12,12 +13,23 @@ const publicRoutes = [
"/api/v1/auth",
"/api/v1/user",
"/api/v1/category",
"/api/v1/auth/oauth",
"/register",
"/auth"
]
export function isRouteProtected(path: string) {
export function isRouteProtected(url: URL | undefined) {
if (url === undefined) {
return false;
}
if (browser && url.hostname !== window.location.hostname) {
return false;
}
const path = url.pathname
if (env.PUBLIC_PRIVATE_INSTANCE == "true") {
return !publicRoutes.some(allowedPath =>