Unverified Commit b09bbad5 authored by Milan K's avatar Milan K Committed by GitHub

Auth0 V2 migration update (#45302)

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Hi Next.js team,  

This PR aims to update examples/auth0 with Auth0 V2 and fix profile api console error.

https://github.com/auth0/nextjs-auth0/blob/v2.0.0/V2_MIGRATION_GUIDE.md

Thanks for the review.
parent e43f134c
......@@ -6,7 +6,7 @@
"start": "next start"
},
"dependencies": {
"@auth0/nextjs-auth0": "^1.9.1",
"@auth0/nextjs-auth0": "^2.2.0",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
......
import { UserProvider } from '@auth0/nextjs-auth0'
import { UserProvider } from '@auth0/nextjs-auth0/client'
export default function App({ Component, pageProps }) {
// optionally pass the 'user' prop from pages that require server-side
......
import { useUser } from '@auth0/nextjs-auth0'
import { useUser } from '@auth0/nextjs-auth0/client'
import Layout from '../components/layout'
const About = () => {
......
import { useEffect, useState } from 'react'
import { useUser } from '@auth0/nextjs-auth0'
import { useUser } from '@auth0/nextjs-auth0/client'
import Layout from '../../components/layout'
const ApiProfile = () => {
......
......@@ -4,7 +4,7 @@ import { withApiAuthRequired, getSession } from '@auth0/nextjs-auth0'
// Protected API, requests to '/api/protected' without a valid session cookie will fail
async function handle(req, res) {
const { user } = getSession(req, res)
const { user } = await getSession(req, res)
try {
res.status(200).json({
......
import { useUser } from '@auth0/nextjs-auth0'
import { useUser } from '@auth0/nextjs-auth0/client'
import Layout from '../components/layout'
const Home = () => {
......
import { withPageAuthRequired } from '@auth0/nextjs-auth0'
import { withPageAuthRequired } from '@auth0/nextjs-auth0/client'
import Layout from '../components/layout'
import { User } from '../interfaces'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment