未验证 提交 9590a8a9 编写于 作者: V Vincent Voyer 提交者: GitHub

docs(examples): upgrade next-iron-session to v4 (#12398)

上级 922b0ecc
......@@ -12,6 +12,11 @@ It uses current best practices for authentication in the Next.js ecosystem.
- Layout based on the user's logged-in/out status
- Session data is signed and encrypted in a cookie
[`next-iron-session`](https://github.com/vvo/next-iron-session) also supports:
- Express / Connect middlewares
- Multiple encryption keys (password) to allow for seamless updates or just password rotation
---
<p align="center"><b>Online demo at <a href="https://next-iron-session.now.sh/">https://next-iron-session.now.sh/</a> 👀</b></p>
......
// this file is a wrapper with defaults to be used in both API routes and `getServerSideProps` functions
import withIronSession from 'next-iron-session'
import { withIronSession } from 'next-iron-session'
export default function withSession(handler) {
return withIronSession(handler, {
......@@ -7,6 +7,7 @@ export default function withSession(handler) {
// ⚠️ Do not reuse the same password, create a different password for you and store it in a secret management system
// Example for Zeit's now: https://vercel.com/docs/v2/serverless-functions/env-and-secrets
password: process.env.SECRET_COOKIE_PASSWORD,
cookieName: 'next.js/examples/with-iron-session',
cookieOptions: {
// the next line allows to use the session in non-https environements like
// Next.js dev mode (http://localhost:3000)
......
......@@ -8,12 +8,12 @@
"start": "next start"
},
"dependencies": {
"next": "9.3.0",
"next-iron-session": "3.1.0",
"next": "9.3.6",
"next-iron-session": "4.0.0",
"node-fetch": "2.6.0",
"prop-types": "15.7.2",
"react": "16.13.0",
"react-dom": "16.13.0",
"swr": "0.1.18"
"react": "16.13.1",
"react-dom": "16.13.1",
"swr": "0.2.0"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册