Skip to content

Commit

Permalink
chore: simplify middleware unleash cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-run committed Aug 26, 2024
1 parent 52febfe commit 33045e6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ export default async function middleware(req: NextRequest): Promise<NextResponse
res.headers.set('x-path', url.pathname + url.search)

const existingCookie = req.cookies.get(UNLEASH_COOKIE_NAME)
if (existingCookie != null) {
return res
if (existingCookie == null) {
res.cookies.set(UNLEASH_COOKIE_NAME, randomSessionId())
}

res.cookies.set(UNLEASH_COOKIE_NAME, randomSessionId())

return res
}

Expand Down

0 comments on commit 33045e6

Please sign in to comment.