Skip to content

Commit

Permalink
fix: check for cookie presence
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 6, 2022
1 parent 9c8e9e5 commit db56991
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ export async function middleware(request) {
url.searchParams.get('path') === 'rewrite-me-without-hard-navigation'
) {
url.searchParams.set('middleware', 'foo')
url.pathname =
request.cookies.get('about-bypass') === '1'
? '/rewrites/about-bypass'
: '/rewrites/about'
url.pathname = request.cookies.has('about-bypass')
? '/rewrites/about-bypass'
: '/rewrites/about'

const response = NextResponse.rewrite(url)
response.headers.set('x-middleware-cache', 'no-cache')
Expand Down

0 comments on commit db56991

Please sign in to comment.