fix: use temporary redirects for auth checks in getServerSideProps

Replace permanent (301) redirects with temporary (302) redirects across
all pages that check authentication state in getServerSideProps.

Permanent redirects are cached by the browser indefinitely, causing a
bug where users had to manually refresh after login: the browser would
cache the unauthenticated redirect (dashboard → login page) and replay
it even after a successful login, preventing navigation to the dashboard.

Fixes #4220
This commit is contained in:
Mauricio Siu
2026-04-30 18:46:12 -06:00
parent 5fb365c08b
commit c854a38adb
42 changed files with 68 additions and 68 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+1 -1
View File
@@ -24,7 +24,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+2 -2
View File
@@ -95,7 +95,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -104,7 +104,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -1827,7 +1827,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -451,7 +451,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -455,7 +455,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -307,7 +307,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -336,7 +336,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -340,7 +340,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -318,7 +318,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -324,7 +324,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -329,7 +329,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+1 -1
View File
@@ -56,7 +56,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+2 -2
View File
@@ -17,7 +17,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -26,7 +26,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+2 -2
View File
@@ -34,7 +34,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -43,7 +43,7 @@ export async function getServerSideProps(
if (!user || (user.role !== "owner" && user.role !== "admin")) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+1 -1
View File
@@ -45,7 +45,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -27,7 +27,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (!user) {
return {
redirect: { destination: "/", permanent: true },
redirect: { destination: "/", permanent: false },
};
}
@@ -23,7 +23,7 @@ export async function getServerSideProps(
if (!IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -33,7 +33,7 @@ export async function getServerSideProps(
if (!user || user.role !== "owner") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -28,7 +28,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -27,7 +27,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -36,7 +36,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -28,7 +28,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -27,7 +27,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -53,7 +53,7 @@ export async function getServerSideProps(
if (!userPermissions?.gitProviders.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -23,7 +23,7 @@ export async function getServerSideProps(
if (!IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -33,7 +33,7 @@ export async function getServerSideProps(
if (!user || user.role !== "owner") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -38,7 +38,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -46,7 +46,7 @@ export async function getServerSideProps(
if (user.role !== "owner") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/settings/profile",
},
};
@@ -28,7 +28,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -54,7 +54,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -28,7 +28,7 @@ export async function getServerSideProps(
if (!user || user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -44,7 +44,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -53,7 +53,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -61,7 +61,7 @@ export async function getServerSideProps(
if (user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/settings/profile",
},
};
@@ -28,7 +28,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -36,7 +36,7 @@ export async function getServerSideProps(
if (user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/settings/profile",
},
};
@@ -27,7 +27,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -54,7 +54,7 @@ export async function getServerSideProps(
if (!userPermissions?.sshKeys.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -46,7 +46,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -54,7 +54,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (user.role === "member") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/settings/profile",
},
};
@@ -47,7 +47,7 @@ export async function getServerSideProps(
if (!userPermissions?.tag.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -39,7 +39,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -66,7 +66,7 @@ export async function getServerSideProps(
if (!userPermissions?.member.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -46,7 +46,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -54,7 +54,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (user.role !== "owner") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/settings/profile",
},
};
+3 -3
View File
@@ -45,7 +45,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -54,7 +54,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -80,7 +80,7 @@ export async function getServerSideProps(
if (!userPermissions?.docker.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+3 -3
View File
@@ -23,7 +23,7 @@ export async function getServerSideProps(
if (IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -32,7 +32,7 @@ export async function getServerSideProps(
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -58,7 +58,7 @@ export async function getServerSideProps(
if (!userPermissions?.traefikFiles.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+3 -3
View File
@@ -407,7 +407,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
@@ -425,7 +425,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (!hasAdmin) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/register",
},
};
@@ -436,7 +436,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
+4 -4
View File
@@ -333,7 +333,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
// if (IS_CLOUD) {
// return {
// redirect: {
// permanent: true,
// permanent: false,
// destination: "/",
// },
// };
@@ -342,7 +342,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (typeof token !== "string") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -365,7 +365,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
if (invitation.isExpired) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -382,7 +382,7 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
console.log("error", error);
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+1 -1
View File
@@ -302,7 +302,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/dashboard/home",
},
};
+2 -2
View File
@@ -190,7 +190,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (!IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -200,7 +200,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (typeof token !== "string") {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+1 -1
View File
@@ -168,7 +168,7 @@ export async function getServerSideProps(_context: GetServerSidePropsContext) {
if (!IS_CLOUD) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
+2 -2
View File
@@ -82,7 +82,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (!user) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};
@@ -103,7 +103,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (!userPermissions?.api.read) {
return {
redirect: {
permanent: true,
permanent: false,
destination: "/",
},
};