Fix logout (add missing nginx auth proxy) + show name/email in sidebar footer

The /cashup/api/auth/ → central auth nginx block was missing, so the logout
POST was hitting the app backend and returning 404 — cookie never cleared,
user stayed logged in. Also removes the stale navigate('/login') call and
shows name + email in the sidebar footer instead of name in the header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-22 11:09:59 +00:00
parent 5aafc0e99f
commit 349fbb335c
2 changed files with 14 additions and 5 deletions

View file

@ -25,6 +25,14 @@ server {
try_files $uri =404;
}
location /cashup/api/auth/ {
proxy_pass http://10.10.10.101:3001/api/auth/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Cache-Control "no-store";
}
location /cashup/api/ {
proxy_pass http://backend:3001/api/;
proxy_set_header Host $host;

View file

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'
import { NavLink, useNavigate, useLocation } from 'react-router-dom'
import { NavLink, useLocation } from 'react-router-dom'
import {
Banknote, ClipboardList, BarChart2, Wallet, Vault, FileText, Settings, LogOut, Menu,
} from 'lucide-react'
@ -33,7 +33,6 @@ const navItems: { to: string; label: string; icon: typeof Banknote; cap?: Cashup
]
export function Layout({ user, children }: Props) {
const navigate = useNavigate()
const location = useLocation()
const isMobile = useIsMobile()
const [menuOpen, setMenuOpen] = useState(false)
@ -42,7 +41,6 @@ export function Layout({ user, children }: Props) {
async function logout() {
await fetch('/cashup/api/auth/logout', { method: 'POST', credentials: 'include' })
navigate('/login', { replace: true })
window.location.reload()
}
@ -62,7 +60,6 @@ export function Layout({ user, children }: Props) {
<Banknote size={20} strokeWidth={1.75} color="var(--gold)" />
<span style={{ color: 'var(--gold)', fontWeight: 700, fontSize: '1rem' }}>Cash Up</span>
</div>
<p style={{ color: 'var(--text-muted)', fontSize: '0.75rem', marginTop: '0.25rem' }}>{user.name}</p>
</div>
<div className="nav-scroll" style={{ flex: 1, padding: '0.5rem 0', overflowY: 'auto' }}>
@ -82,10 +79,14 @@ export function Layout({ user, children }: Props) {
</div>
<div style={{ padding: '0.75rem 1rem', borderTop: '1px solid var(--surface-2)' }}>
<div style={{ marginBottom: '0.5rem' }}>
<div style={{ color: 'var(--text)', fontSize: '0.8rem', fontWeight: 600 }}>{user.name}</div>
<div style={{ color: 'var(--text-muted)', fontSize: '0.72rem' }}>{user.email}</div>
</div>
<button onClick={logout} style={{
display: 'flex', alignItems: 'center', gap: '0.5rem',
background: 'none', border: 'none', color: 'var(--text-muted)',
fontSize: '0.875rem', padding: '0.375rem 0', width: '100%',
fontSize: '0.8rem', padding: '0.375rem 0', width: '100%', cursor: 'pointer',
}}>
<LogOut size={14} strokeWidth={1.75} />
Sign out