Skip to content

Commit 5fc4404

Browse files
committed
feat(*): avoid extra DNS lookup, add note
1 parent 5d807e9 commit 5fc4404

File tree

8 files changed

+30
-11
lines changed

8 files changed

+30
-11
lines changed

apps/frontend/app/lib/hooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const useUserMetadataDetails = (metadataId?: string | null) => {
115115
return useQuery(getUserMetadataDetailsQuery(metadataId));
116116
};
117117

118-
const useDashboardLayoutData = () => {
118+
export const useDashboardLayoutData = () => {
119119
const loaderData =
120120
useRouteLoaderData<typeof dashboardLoader>("routes/_dashboard");
121121
return loaderData;

apps/frontend/app/lib/utilities.server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
toastKey,
4242
} from "~/lib/generals";
4343

44-
export const API_URL = process.env.API_URL || "http://localhost:8000/backend";
44+
export const API_URL = process.env.API_URL || "http://127.0.0.1:8000/backend";
4545

4646
class AuthenticatedGraphQLClient extends GraphQLClient {
4747
async authenticatedRequest<T, V extends Variables = Variables>(
@@ -130,6 +130,7 @@ const expectedServerVariables = z.object({
130130
FRONTEND_OIDC_BUTTON_LABEL: z
131131
.string()
132132
.default("Continue with OpenID Connect"),
133+
FRONTEND_DASHBOARD_MESSAGE: z.string().optional(),
133134
});
134135

135136
/**

apps/frontend/app/routes/_dashboard._index.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { $path } from "@ignisda/remix-routes";
22
import {
3+
Alert,
34
Box,
45
Center,
56
Container,
@@ -28,6 +29,7 @@ import { humanizeDuration, isNumber } from "@ryot/ts-utils";
2829
import {
2930
IconBarbell,
3031
IconFriends,
32+
IconInfoCircle,
3133
IconScaleOutline,
3234
IconServer,
3335
} from "@tabler/icons-react";
@@ -42,6 +44,7 @@ import {
4244
} from "~/components/media";
4345
import { dayjsLib, getLot, getMetadataIcon } from "~/lib/generals";
4446
import {
47+
useDashboardLayoutData,
4548
useGetMantineColor,
4649
useUserPreferences,
4750
useUserUnitSystem,
@@ -108,11 +111,17 @@ export default function Page() {
108111
const userPreferences = useUserPreferences();
109112
const unitSystem = useUserUnitSystem();
110113
const theme = useMantineTheme();
114+
const dashboardLayoutData = useDashboardLayoutData();
111115
const latestUserSummary = loaderData.latestUserSummary.data;
112116

113117
return (
114118
<Container>
115119
<Stack gap={32}>
120+
{dashboardLayoutData.envData.FRONTEND_DASHBOARD_MESSAGE ? (
121+
<Alert variant="default" icon={<IconInfoCircle />}>
122+
{dashboardLayoutData.envData.FRONTEND_DASHBOARD_MESSAGE}
123+
</Alert>
124+
) : null}
116125
{userPreferences.general.dashboard.map((de) =>
117126
match([de.section, de.hidden])
118127
.with([DashboardElementLot.Upcoming, false], () =>

apps/frontend/app/routes/_dashboard.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,21 @@ export const loader = unstable_defineLoader(async ({ request }) => {
259259

260260
export function ErrorBoundary() {
261261
const error = useRouteError() as Error;
262+
const message = isRouteErrorResponse(error)
263+
? error.data.message
264+
: error.message;
262265

263266
return (
264267
<Container size="sm" py={{ base: 100, md: 200 }}>
265268
<Stack p={{ base: "sm", md: "xl" }}>
266269
<Text c="red" fz={{ base: 30, md: 40 }}>
267270
We encountered an error
268271
</Text>
269-
<Code mah={100} c="pink">
270-
{isRouteErrorResponse(error) ? error.data.message : error.message}
271-
</Code>
272+
{message ? (
273+
<Code mah={100} c="pink">
274+
{message}
275+
</Code>
276+
) : null}
272277
<Group wrap="nowrap">
273278
<Button
274279
fullWidth

apps/frontend/app/routes/auth.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ export const loader = unstable_defineLoader(async ({ request }) => {
8484
closeAfter: dayjsLib.duration(10, "second").asMilliseconds(),
8585
},
8686
);
87-
throw await redirectWithToast($path("/"), {
88-
message: "You were already logged in",
89-
});
87+
throw redirect($path("/"));
9088
}
9189
const [enabledFeatures, { coreDetails }] = await Promise.all([
9290
getCoreEnabledFeatures(),

ci/Caddyfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
:{$PORT:8000} {
77
handle_path /_i/* {
88
rewrite * /webhooks/integrations{path}
9-
reverse_proxy localhost:5000
9+
reverse_proxy 127.0.0.1:5000
1010
}
1111
handle_path /backend* {
12-
reverse_proxy localhost:5000
12+
reverse_proxy 127.0.0.1:5000
1313
}
1414
handle /health {
1515
header Content-Type text/plain
@@ -19,5 +19,5 @@
1919
{{ httpInclude "/backend/config" }}
2020
TXT
2121
}
22-
reverse_proxy localhost:3000
22+
reverse_proxy 127.0.0.1:3000
2323
}

docs/includes/backend-config-schema.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ file_storage:
7777

7878
# Settings related to frontend storage.
7979
frontend:
80+
# A message to be displayed on the dashboard.
81+
# @envvar FRONTEND_DASHBOARD_MESSAGE
82+
dashboard_message: ""
83+
8084
# The button label for OIDC authentication.
8185
# @envvar FRONTEND_OIDC_BUTTON_LABEL
8286
oidc_button_label: "Continue with OpenID Connect"

libs/config/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ pub struct FrontendConfig {
296296
/// The button label for OIDC authentication.
297297
#[setting(default = "Continue with OpenID Connect")]
298298
pub oidc_button_label: String,
299+
/// A message to be displayed on the dashboard.
300+
pub dashboard_message: String,
299301
/// Settings related to Umami analytics.
300302
#[setting(nested)]
301303
pub umami: FrontendUmamiConfig,

0 commit comments

Comments
 (0)