Skip to content

Open-source status page, incident response and uptime monitoring

fix: url protocol error (#1692)

Maximilian Kaskefa3744a0a88f
diff --git a/apps/status-page/src/app/(status-page)/[domain]/(auth)/login/actions.ts b/apps/status-page/src/app/(status-page)/[domain]/(auth)/login/actions.ts
index 87c433fcc..1dd8ff455 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/(auth)/login/actions.ts
+++ b/apps/status-page/src/app/(status-page)/[domain]/(auth)/login/actions.ts
@@ -17,9 +17,19 @@ export async function signInWithResendAction(formData: FormData) {
const queryClient = getQueryClient();
// NOTE: throws an error if the email domain is not allowed
- await queryClient.fetchQuery(
- trpc.statusPage.validateEmailDomain.queryOptions({ slug: domain, email }),
- );
+ try {
+ await queryClient.fetchQuery(
+ trpc.statusPage.validateEmailDomain.queryOptions({
+ slug: domain,
+ email,
+ }),
+ );
+ } catch (error) {
+ console.error("[SignIn] Email validation failed", error);
+ throw new Error(
+ "Your email domain is not authorized to access this status page",
+ );
+ }
await signIn("resend", {
email,
@@ -28,10 +38,14 @@ export async function signInWithResendAction(formData: FormData) {
} catch (e) {
// NOTE: https://github.com/nextauthjs/next-auth/discussions/9389
if (isRedirectError(e)) return;
- console.error(e);
+ console.error("[SignIn] Error:", e);
if (e instanceof AuthError) {
throw new Error(`Authentication error: ${e.type}`);
}
- throw e;
+ if (e instanceof Error) {
+ // Re-throw the error with the original message
+ throw e;
+ }
+ throw new Error("An unexpected error occurred during sign in");
}
}
diff --git a/apps/status-page/src/components/forms/form-email.tsx b/apps/status-page/src/components/forms/form-email.tsx
index 7b4f206b1..cf03e23e7 100644
--- a/apps/status-page/src/components/forms/form-email.tsx
+++ b/apps/status-page/src/components/forms/form-email.tsx
@@ -1,6 +1,6 @@
"use client";
-import { Form } from "@/components/ui/form";
+import { Form, FormMessage } from "@/components/ui/form";
import {
FormControl,
FormField,
@@ -76,6 +76,7 @@ export function FormEmail({
<FormControl>
<Input type="email" {...field} />
</FormControl>
+ <FormMessage />
</FormItem>
)}
/>
diff --git a/apps/status-page/src/lib/auth/index.ts b/apps/status-page/src/lib/auth/index.ts
index de82813a4..8ecba2953 100644
--- a/apps/status-page/src/lib/auth/index.ts
+++ b/apps/status-page/src/lib/auth/index.ts
@@ -23,7 +23,10 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
if (!host) throw new AuthError("No host found");
- const req = new Request(host, { headers: new Headers(_headers) });
+ const protocol = _headers.get("x-forwarded-proto") || "https";
+ const req = new Request(`${protocol}://${host}`, {
+ headers: new Headers(_headers),
+ });
const { prefix } = getValidCustomDomain(req);
if (!prefix || !params.user.email) return false;