diff --git a/site/src/pages/continue-page.tsx b/site/src/pages/continue-page.tsx
index f7956e5..33b79ae 100644
--- a/site/src/pages/continue-page.tsx
+++ b/site/src/pages/continue-page.tsx
@@ -4,6 +4,7 @@ import { Navigate } from "react-router";
 import { useUserContext } from "../context/user-context";
 import { Layout } from "../components/layouts/layout";
 import { ReactNode } from "react";
+import { isQueryValid } from "../utils/utils";
 
 export const ContinuePage = () => {
   const queryString = window.location.search;
@@ -16,7 +17,7 @@ export const ContinuePage = () => {
     return ;
   }
 
-  if (redirectUri === "null" || redirectUri === "") {
+  if (!isQueryValid(redirectUri)) {
     return ;
   }
 
diff --git a/site/src/pages/login-page.tsx b/site/src/pages/login-page.tsx
index ebfbb2d..db25284 100644
--- a/site/src/pages/login-page.tsx
+++ b/site/src/pages/login-page.tsx
@@ -20,6 +20,7 @@ import { GoogleIcon } from "../icons/google";
 import { GithubIcon } from "../icons/github";
 import { OAuthIcon } from "../icons/oauth";
 import { TailscaleIcon } from "../icons/tailscale";
+import { isQueryValid } from "../utils/utils";
 
 export const LoginPage = () => {
   const queryString = window.location.search;
@@ -70,7 +71,7 @@ export const LoginPage = () => {
         color: "green",
       });
       setTimeout(() => {
-        if (redirectUri === "null" || redirectUri === "") {
+        if (isQueryValid(redirectUri)) {
           window.location.replace("/");
         } else {
           window.location.replace(`/continue?redirect_uri=${redirectUri}`);
diff --git a/site/src/pages/unauthorized-page.tsx b/site/src/pages/unauthorized-page.tsx
index c5b0f81..3bc688a 100644
--- a/site/src/pages/unauthorized-page.tsx
+++ b/site/src/pages/unauthorized-page.tsx
@@ -1,6 +1,7 @@
 import { Button, Code, Paper, Text } from "@mantine/core";
 import { Layout } from "../components/layouts/layout";
 import { Navigate } from "react-router";
+import { isQueryValid } from "../utils/utils";
 
 export const UnauthorizedPage = () => {
   const queryString = window.location.search;
@@ -8,7 +9,7 @@ export const UnauthorizedPage = () => {
   const username = params.get("username") ?? "";
   const resource = params.get("resource") ?? "";
 
-  if (username === "null" || username === "") {
+  if (!isQueryValid(username)) {
     return ;
   }
 
@@ -20,7 +21,7 @@ export const UnauthorizedPage = () => {
         
         
           The user with username {username} is not authorized to{" "}
-          {resource !== "null" && resource !== "" ? (
+          {isQueryValid(resource) ? (
             
               access the {resource} resource.
             
diff --git a/site/src/utils/utils.ts b/site/src/utils/utils.ts
index 7433da7..038230e 100644
--- a/site/src/utils/utils.ts
+++ b/site/src/utils/utils.ts
@@ -1 +1,2 @@
-export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
\ No newline at end of file
+export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
+export const isQueryValid = (value: string) => value.trim() !== "" && value !== "null";