Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mosu-app/src/pages/notice/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
props: { profileData },
};
} catch (error) {
if (error instanceof UnauthorizedException || error instanceof ForbiddenException) {
if (error instanceof UnauthorizedException) {
return {
Comment on lines +30 to 31
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Harden 401 detection beyond instanceof.

Cross-bundle instanceof checks can fail. Also check status codes.

-        if (error instanceof UnauthorizedException) {
+        if (
+            error instanceof UnauthorizedException ||
+            (error as any)?.status === 401 ||
+            (error as any)?.response?.status === 401
+        ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (error instanceof UnauthorizedException) {
return {
if (
error instanceof UnauthorizedException ||
(error as any)?.status === 401 ||
(error as any)?.response?.status === 401
) {
return {
// …
🤖 Prompt for AI Agents
In mosu-app/src/pages/notice/new.tsx around lines 30-31, the code only checks
error instanceof UnauthorizedException which can fail across bundles; change the
conditional to also detect a 401 by checking common status properties (e.g.
error.status === 401 || error.response?.status === 401 || error.statusCode ===
401) and keep the existing UnauthorizedException branch behavior when any of
these checks are true; ensure the combined condition is used wherever
UnauthorizedException was checked so 401 responses are reliably handled
regardless of instanceof mismatches.

redirect: {
destination: "/auth/member/signin?returnUrl=/notice/new",
Expand All @@ -41,6 +41,13 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
permanent: false,
},
};
} else {
return {
redirect: {
destination: "/auth/member/signin?returnUrl=/notice/new",
permanent: false,
},
};
}
}
};
Expand Down