fix: ssr session on teams page
This commit is contained in:
		
							parent
							
								
									6f64df3e75
								
							
						
					
					
						commit
						2008ad263c
					
				
					 2 changed files with 17 additions and 2 deletions
				
			
		|  | @ -1,8 +1,9 @@ | |||
| import '../styles/globals.css'; | ||||
| import {createTelemetryClient, TelemetryProvider} from '../lib/telemetry'; | ||||
| import { Provider } from 'next-auth/client'; | ||||
| import type { AppProps } from "next/app" | ||||
| 
 | ||||
| function MyApp({ Component, pageProps }) { | ||||
| function MyApp({ Component, pageProps }: AppProps) { | ||||
|   return ( | ||||
|       <TelemetryProvider value={createTelemetryClient()}> | ||||
|         <Provider session={pageProps.session}> | ||||
|  |  | |||
|  | @ -1,8 +1,10 @@ | |||
| import { GetServerSideProps } from "next" | ||||
| import Head from 'next/head'; | ||||
| import Shell from '../../components/Shell'; | ||||
| import SettingsShell from '../../components/Settings'; | ||||
| import { useEffect, useState } from 'react'; | ||||
| import { useSession } from 'next-auth/client'; | ||||
| import type { Session } from "next-auth" | ||||
| import { useSession, getSession } from 'next-auth/client'; | ||||
| import { | ||||
|   UsersIcon, | ||||
| } from "@heroicons/react/outline"; | ||||
|  | @ -165,3 +167,15 @@ export default function Teams() { | |||
|     </Shell> | ||||
|   ); | ||||
| } | ||||
| 
 | ||||
| // Export the `session` prop to use sessions with Server Side Rendering
 | ||||
| export const getServerSideProps: GetServerSideProps<{session: Session | null}> = async (context) => { | ||||
|     const session = await getSession(context); | ||||
|     if (!session) { | ||||
|       return { redirect: { permanent: false, destination: '/auth/login' } }; | ||||
|     } | ||||
| 
 | ||||
|     return { | ||||
|       props: { session } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 mihaic195
						mihaic195