feat(ST-903): load active product in layout, replace cookie with DB lookup in solo
- layout.tsx: fetch active_product_id, resolve product, clear stale ref server-side - NavBar: add activeProduct prop (rendering changes in ST-904) - solo/page.tsx: redirect via user.active_product_id instead of lastProductId cookie - proxy.ts: remove lastProductId cookie logic - lib/cookies.ts: deleted (no longer used) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
35d60cc43b
commit
12d81a172f
5 changed files with 34 additions and 44 deletions
18
proxy.ts
18
proxy.ts
|
|
@ -5,9 +5,6 @@ import { sessionOptions } from '@/lib/session'
|
|||
const protectedRoutes = ['/dashboard', '/products', '/todos', '/settings', '/solo']
|
||||
const authRoutes = ['/login', '/register']
|
||||
|
||||
const SOLO_ROUTE = /^\/products\/([^/]+)\/solo$/
|
||||
const THIRTY_DAYS_SECONDS = 60 * 60 * 24 * 30
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const path = request.nextUrl.pathname
|
||||
const isProtected = protectedRoutes.some(r => path.startsWith(r))
|
||||
|
|
@ -24,20 +21,7 @@ export function proxy(request: NextRequest) {
|
|||
return NextResponse.redirect(new URL('/dashboard', request.url))
|
||||
}
|
||||
|
||||
const response = NextResponse.next()
|
||||
|
||||
// Remember last visited product for /solo redirect
|
||||
const soloMatch = path.match(SOLO_ROUTE)
|
||||
if (soloMatch) {
|
||||
response.cookies.set('lastProductId', soloMatch[1], {
|
||||
httpOnly: true,
|
||||
sameSite: 'lax',
|
||||
maxAge: THIRTY_DAYS_SECONDS,
|
||||
path: '/',
|
||||
})
|
||||
}
|
||||
|
||||
return response
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
export const config = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue