You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 700B

12345678910111213141516171819202122232425262728293031323334
  1. import * as React from 'react'
  2. import type { GetServerSideProps } from 'next'
  3. import Head from 'next/head'
  4. interface RoomProps {
  5. id?: string
  6. }
  7. export default function RandomRoomPage({ id }: RoomProps): JSX.Element {
  8. return (
  9. <>
  10. <Head>
  11. <title>tldraw</title>
  12. </Head>
  13. <div>Should have routed to room: {id}</div>
  14. </>
  15. )
  16. }
  17. export const getServerSideProps: GetServerSideProps = async (context) => {
  18. // Generate random id
  19. const id = Date.now().toString()
  20. // Route to a room with that id
  21. context.res.setHeader('Location', `/r/${id}`)
  22. context.res.statusCode = 307
  23. // Return id (though it shouldn't matter)
  24. return {
  25. props: {
  26. id,
  27. },
  28. }
  29. }