2021-09-04 12:18:44 +00:00
|
|
|
import * as React from 'react'
|
|
|
|
import type { GetServerSideProps } from 'next'
|
2021-09-06 13:37:48 +00:00
|
|
|
import Head from 'next/head'
|
2021-09-04 12:18:44 +00:00
|
|
|
|
|
|
|
interface RoomProps {
|
|
|
|
id?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function RandomRoomPage({ id }: RoomProps): JSX.Element {
|
2021-09-06 13:37:48 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Head>
|
|
|
|
<title>tldraw</title>
|
|
|
|
</Head>
|
|
|
|
<div>Should have routed to room: {id}</div>
|
|
|
|
</>
|
|
|
|
)
|
2021-09-04 12:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
// Generate random id
|
|
|
|
const id = Date.now().toString()
|
|
|
|
|
|
|
|
// Route to a room with that id
|
|
|
|
context.res.setHeader('Location', `/r/${id}`)
|
|
|
|
context.res.statusCode = 307
|
|
|
|
|
|
|
|
// Return id (though it shouldn't matter)
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|