fix: allow unauthenticated users to view certificates

- Updated API error interceptor to skip redirect on certificate pages
- Prevents 401 errors from redirecting to login on public certificate pages
- Certificate pages can now be viewed without authentication

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Maulana Sodiqin
2025-12-10 22:01:37 +07:00
co-authored by Claude
parent 1dbe704230
commit da8b08cd73
+4 -3
View File
@@ -31,12 +31,13 @@ hackathonApi.interceptors.response.use(
(response) => response,
(error) => {
// Handle 401 - clear session and redirect to login
// But skip redirect if already on auth pages (to avoid reload on login failure)
// But skip redirect if already on auth pages or certificate pages (to avoid reload on login failure)
if (error.response?.status === 401) {
const isAuthPage = globalThis.window !== undefined && globalThis.location.pathname.startsWith('/auth');
const isCertificatePage = globalThis.window !== undefined && globalThis.location.pathname.startsWith('/certificate/');
// Only clear session and redirect if not on auth page
if (!isAuthPage) {
// Only clear session and redirect if not on auth page or certificate page
if (!isAuthPage && !isCertificatePage) {
useAuthStore.getState().clearSession();
if (globalThis.window !== undefined) {
globalThis.location.href = '/auth/login';