-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cookie support, replaced deprecated interceptor with handle
Fix #2
- Loading branch information
1 parent
a4b3f5e
commit 6ed70f9
Showing
8 changed files
with
254 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
import { NextResponse as Response } from 'next/server'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function POST(req: Request) { | ||
return Response.json({ message: 'Hello from Next.js! in response to ' + (await req.text()) }); | ||
export async function POST(req: NextRequest) { | ||
const iteration = parseInt(req.cookies.get('iteration')?.value, 10) || 0; | ||
|
||
const res = NextResponse.json({ message: 'Hello from Next.js! in response to ' + (await req.text()) }); | ||
|
||
res.cookies.set('iteration', (iteration + 1).toString(), { | ||
path: '/', | ||
maxAge: 60 * 60, // 1 hour | ||
}); | ||
|
||
res.cookies.set('date', Date.now().toString(), { | ||
path: '/', | ||
maxAge: 60 * 60, // 1 hour | ||
}); | ||
|
||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.