Configure Fauna database
- Head over to Fauna and create an account if you haven’t done so already.
- Next, create a new database. Give your database a name. Select the classic region group and select create.
Info: By default, Fauna allows you to save your data globally closer to your user. However, you can also limit your data's distribution to a specific geographic region group to comply with GDPR and data residency. Learn more about region groups here.
You also have the option to save data into privately distributed nodes with Virtual Private Fauna.
- Next, select create new collection.
- Create a new Collection called
Products
.
- You would require a secret to query your database from your application. Navigate to Security > Keys and select New Key.
- Select
Server
Role from the dropdown. Give your key a name and select Save. When the key is generated save it into a secure file.
- For local development create a new file called
.env
in the root of your project and add the following code. Make sure you add.env
to your git ignore file so it doesn’t get committed.
FAUNA_SECRET=fnAExxxx
- Finally, head back to Cloudflare Pages settings and add a new environment variable called FAUNA_SECRET.
Last updated on November 30, 2022