Skip to content

Commit 7873b03

Browse files
MikeEdgarclaude
andcommitted
Fix timeZone errors, refine config fetching
Signed-off-by: Michael Edgar <medgar@redhat.com> Assisted-by: Claude Code (Sonnet 4.5) <noreply@anthropic.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d0fdd0a commit 7873b03

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

ui/app/[locale]/NextIntlProvider.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import { AbstractIntlMessages, NextIntlClientProvider } from "next-intl";
3-
import { ReactNode } from "react";
3+
import { ReactNode, useState, useEffect } from "react";
44

55
type Props = {
66
messages: AbstractIntlMessages;
@@ -12,7 +12,14 @@ export default function NextIntlProvider({
1212
locale,
1313
children,
1414
}: Props) {
15-
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
15+
// Use UTC as default for SSR to avoid hydration mismatch
16+
// Client will update to actual timezone after mount
17+
const [timeZone, setTimeZone] = useState<string>("UTC");
18+
19+
useEffect(() => {
20+
setTimeZone(Intl.DateTimeFormat().resolvedOptions().timeZone);
21+
}, []);
22+
1623
return (
1724
<NextIntlClientProvider
1825
locale={locale}

ui/middleware.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ const authMiddleware = withAuth(
2828
},
2929
) as any;
3030

31-
const publicPathnameRegex = RegExp(
31+
const publicPathnameRegex = new RegExp(
3232
`^(/(${locales.join("|")}))?(${publicPages
3333
.flatMap((p) => (p === "/" ? ["", "/"] : p))
3434
.join("|")})/?$`,
3535
"i",
3636
);
3737

38-
const protectedPathnameRegex = RegExp(
38+
const protectedPathnameRegex = new RegExp(
3939
`^(/(${locales.join("|")}))?(${protectedPages
4040
.flatMap((p) => (p === "/" ? ["", "/"] : p))
4141
.join("|")})/?$`,
@@ -47,11 +47,19 @@ export default async function middleware(req: NextRequest) {
4747
* Next.js middleware doesn't support reading files, so here we make a (cached)
4848
* call to the /config endpoint within the same application :(
4949
*/
50-
let oidcEnabled = await fetch(`http://127.0.0.1:${process.env.PORT}/config`, {
50+
const configUrl = `http://127.0.0.1:${process.env.PORT || '3000'}/config`;
51+
log.info({ configUrl }, "Fetching OIDC configuration");
52+
53+
let oidcEnabled = await fetch(configUrl, {
5154
cache: "force-cache",
55+
signal: AbortSignal.timeout(1000), // 1 second timeout to prevent hanging
5256
})
5357
.then((cfg) => cfg.json())
54-
.then((cfg) => cfg["oidc"]);
58+
.then((cfg) => cfg["oidc"])
59+
.catch((err) => {
60+
log.warn({ err, configUrl }, "Failed to fetch OIDC config, defaulting to false");
61+
return false;
62+
});
5563

5664
const searchParams = req.nextUrl.searchParams;
5765
const requestPath = req.nextUrl.pathname;

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "Apache-2.0",
55
"private": true,
66
"scripts": {
7-
"dev": "NODE_OPTIONS='--inspect --require next-logger' next dev | pino-pretty",
7+
"dev": "NODE_OPTIONS='--require next-logger' next dev | pino-pretty",
88
"build": "next build",
99
"start": "NODE_OPTIONS='--require next-logger' next start",
1010
"lint": "next lint",

0 commit comments

Comments
 (0)