diff --git a/nextjs-vercel/README.md b/nextjs-vercel/README.md index 5a9bd91..55bee0c 100644 --- a/nextjs-vercel/README.md +++ b/nextjs-vercel/README.md @@ -40,7 +40,24 @@ yarn create next-app --example https://github.com/whereby/embedded-examples/tree ## Getting Started -First, run the development server: +We are using [Custom Server](https://nextjs.org/docs/advanced-features/custom-server) to run dev server on HTTPS with SSL certificate in `./server.js`. +Note: A custom server can not be deployed on Vercel. + +1. Follow [this guide](https://web.dev/how-to-use-local-https/#setup) to create a certificate for `whereby.localhost.dev`, +```bash +mkcert -install + +mkcert whereby.localhost.dev +``` +and move the resulting files (which should be named `whereby.localhost.dev-key.pem` and `whereby.localhost.dev.pem`) to `https_cert/`. + +2. Add `127.0.0.1 whereby.localhost.dev` as a new line to your `/etc/hosts` file (`sudo vi /etc/hosts`). So you can have local HTTPS. + +3. Go to your Whereby Embedded dashboard and allow the `https://whereby.localhost.dev:3000` domain. + +4. Create a `.env.local` file and add your Whereby Embedded environment variables `WHEREBY_API_KEY=eyJhb...` and `WHEREBY_WEBHOOK_SECRET=3bag9...`. + +5. Run the development server: ```bash npm run dev @@ -48,10 +65,11 @@ npm run dev yarn dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +6. Open [https://whereby.localhost.dev:3000](https://whereby.localhost.dev:3000) with your browser to see the result. You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/whereby/meetings](http://localhost:3000/api/whereby/meetings). This endpoint can be edited in `pages/api/whereby/meetings/index.js`. +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [https://whereby.localhost.dev:3000/api/whereby/meetings](https://whereby.localhost.dev:3000/api/whereby/meetings). +This endpoint can be edited in `pages/api/whereby/meetings/index.js`. The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. diff --git a/nextjs-vercel/components/CreateMeetingAPI/useCreateMeetingAPI.js b/nextjs-vercel/components/CreateMeetingAPI/useCreateMeetingAPI.js index 39107da..d8e7679 100644 --- a/nextjs-vercel/components/CreateMeetingAPI/useCreateMeetingAPI.js +++ b/nextjs-vercel/components/CreateMeetingAPI/useCreateMeetingAPI.js @@ -20,7 +20,6 @@ const text2Array = (_currentValue, originalValue) => { return originalValue.length > 0 ? originalValue.split(",") : []; }; - const now = new Date(); const schema = yup.object().shape({ @@ -31,9 +30,17 @@ const schema = yup.object().shape({ .max(40), roomNamePattern: yup.string().oneOf(["uuid", "human-short"]), roomMode: yup.string().oneOf(["group", "normal"]), - startDate: yup.date().transform(dateInput2Date).min(new Date(now.toDateString())).required(), + startDate: yup + .date() + .transform(dateInput2Date) + .min(new Date(now.toDateString())) + .required(), startTime: yup.date().transform(timeInput2Date).required(), - endDate: yup.date().transform(dateInput2Date).min(new Date(now.toDateString())).required(), + endDate: yup + .date() + .transform(dateInput2Date) + .min(new Date(now.toDateString())) + .required(), endTime: yup.date().transform(timeInput2Date).required(), fields: yup .array() @@ -48,8 +55,8 @@ const defaultValues = { roomMode: "normal", startDate: format(now, "yyyy-LL-dd"), startTime: format(now, "HH:mm"), - endDate: format(add(now, {hours: 1}), "yyyy-LL-dd"), - endTime: format(add(now, {hours: 1}), "HH:mm"), + endDate: format(add(now, { hours: 1 }), "yyyy-LL-dd"), + endTime: format(add(now, { hours: 1 }), "HH:mm"), fields: "", }; diff --git a/nextjs-vercel/components/DeleteMeetingAPI/index.js b/nextjs-vercel/components/DeleteMeetingAPI/index.js index ba5d960..807c761 100644 --- a/nextjs-vercel/components/DeleteMeetingAPI/index.js +++ b/nextjs-vercel/components/DeleteMeetingAPI/index.js @@ -38,7 +38,7 @@ const DeleteMeetingAPI = ({ defaultMeetingId, onMeetingDeleted }) => {