mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 16:56:39 +00:00
* implement reverse proxy --------- Co-authored-by: Alisdair MacLeod <git@alisdairmacleod.co.uk> Co-authored-by: mlsmaycon <mlsmaycon@gmail.com> Co-authored-by: Eduard Gert <kontakt@eduardgert.de> Co-authored-by: Viktor Liu <viktor@netbird.io> Co-authored-by: Diego Noguês <diego.sure@gmail.com> Co-authored-by: Diego Noguês <49420+diegocn@users.noreply.github.com> Co-authored-by: Bethuel Mmbaga <bethuelmbaga12@gmail.com> Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com> Co-authored-by: Ashley Mensah <ashleyamo982@gmail.com>
55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
// Auth method types matching Go
|
|
export type AuthMethod = 'pin' | 'password' | 'oidc' | "link"
|
|
|
|
// Page types
|
|
export type PageType = 'auth' | 'error'
|
|
|
|
// Error data structure
|
|
export interface ErrorData {
|
|
code: number
|
|
title: string
|
|
message: string
|
|
proxy?: boolean
|
|
destination?: boolean
|
|
requestId?: string
|
|
simple?: boolean
|
|
retryUrl?: string
|
|
}
|
|
|
|
// Data injected by Go templates
|
|
export interface Data {
|
|
page?: PageType
|
|
methods?: Partial<Record<AuthMethod, string>>
|
|
error?: ErrorData
|
|
}
|
|
|
|
declare global {
|
|
// eslint-disable-next-line no-var
|
|
var __DATA__: Data | undefined
|
|
}
|
|
|
|
export function getData(): Data {
|
|
const data = globalThis.__DATA__ ?? {}
|
|
|
|
// Dev mode: allow ?page=error query param to preview error page
|
|
if (import.meta.env.DEV) {
|
|
const params = new URLSearchParams(globalThis.location.search)
|
|
const page = params.get('page')
|
|
if (page === 'error') {
|
|
return {
|
|
...data,
|
|
page: 'error',
|
|
error: data.error ?? {
|
|
code: 503,
|
|
title: 'Service Unavailable',
|
|
message: 'The service you are trying to access is temporarily unavailable. Please try again later.',
|
|
proxy: true,
|
|
destination: false,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
return data
|
|
}
|