Skip to content

Commit 4870fb4

Browse files
committed
Fixed nav (im tired)
1 parent 533bcbd commit 4870fb4

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/components/Navbar.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function Navbar() {
1717
<div className="flex justify-between h-16">
1818
{/* Left - Logo */}
1919
<div className="flex items-center">
20-
<Link href="/" className="flex items-center text-white font-bold text-xl">
20+
<Link href="/dashboard" className="flex items-center text-white font-bold text-xl">
2121
CryptoSite
2222
</Link>
2323
</div>
@@ -81,7 +81,7 @@ export default function Navbar() {
8181
Key Generation
8282
</Link>
8383
<Link
84-
href="/steg"
84+
href="/steganography"
8585
className="block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700"
8686
onClick={() => setIsModesOpen(false)}
8787
>

src/middleware.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
import { NextResponse } from 'next/server'
22

33
export function middleware(request) {
4-
// Get the pathname of the request and remove the base path
5-
const path = request.nextUrl.pathname.replace('/crypt-webapp', '')
4+
const path = request.nextUrl.pathname
65

7-
// Define public paths that don't require authentication
8-
const isPublicPath = path === '/' ||
9-
path === '/login' ||
10-
path === '/register'
6+
// Only login and register are public
7+
const isPublicPath = path === '/crypt-webapp/' ||
8+
path === '/crypt-webapp/login' ||
9+
path === '/crypt-webapp/register'
1110

12-
// Get the token from the cookies
1311
const token = request.cookies.get('token')?.value || ''
1412

15-
// Get the base URL for redirects
16-
const baseUrl = new URL('/crypt-webapp', request.url).toString().replace(/\/$/, '')
17-
18-
// Redirect authenticated users away from login/register pages
13+
// If logged in, redirect to dashboard from public pages
1914
if (isPublicPath && token) {
20-
return NextResponse.redirect(`${baseUrl}/dashboard`)
15+
return NextResponse.redirect(new URL('/crypt-webapp/dashboard', request.url))
2116
}
2217

23-
// Redirect unauthenticated users to login page
18+
// If not logged in, redirect to login from private pages
2419
if (!isPublicPath && !token) {
25-
return NextResponse.redirect(`${baseUrl}/login`)
20+
return NextResponse.redirect(new URL('/crypt-webapp/login', request.url))
2621
}
2722
}
2823

0 commit comments

Comments
 (0)