Skip to content

Commit

Permalink
chore: fix unstable_getServerSession usages in dev app (#5017)
Browse files Browse the repository at this point in the history
chore: fix unstable_getServerSession usages in dev app
  • Loading branch information
ThangHuuVu committed Jul 25, 2022
1 parent aedabc8 commit 89829d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/dev/pages/api/examples/protected.js
@@ -1,8 +1,9 @@
// This is an example of to protect an API route
import { unstable_getServerSession } from "next-auth/next"
import { authOptions } from "../auth/[...nextauth]"

export default async (req, res) => {
const session = await unstable_getServerSession(req, res, options)
const session = await unstable_getServerSession(req, res, authOptions)

if (session) {
res.send({
Expand Down
1 change: 1 addition & 0 deletions apps/dev/pages/api/examples/session.js
@@ -1,5 +1,6 @@
// This is an example of how to access a session from an API route
import { unstable_getServerSession } from "next-auth/next"
import { authOptions } from '../auth/[...nextauth]';

export default async (req, res) => {
const session = await unstable_getServerSession(req, res, authOptions)
Expand Down
5 changes: 3 additions & 2 deletions apps/dev/pages/server.js
@@ -1,5 +1,6 @@
import { unstable_getServerSession } from "next-auth/next"
import Layout from "../components/layout"
import { authOptions } from './api/auth/[...nextauth]';

export default function Page() {
// As this page uses Server Side Rendering, the `session` will be already
Expand Down Expand Up @@ -40,8 +41,8 @@ export async function getServerSideProps(context) {
return {
props: {
session: await unstable_getServerSession(
contex.req,
contex.res,
context.req,
context.res,
authOptions
),
},
Expand Down

0 comments on commit 89829d8

Please sign in to comment.