Back

Need Help: Trouble Creating Appwrite Database Configuration

  • 0
  • Self Hosted
  • Databases
  • Web
anyuru
15 Jun, 2023, 16:17

require("dotenv").config(); /**

TL;DR
The user is having trouble creating an Appwrite database configuration. They mention that they can access environment variables and have set them in their local environment. The user is using the server SDK and also provides some sample code. Another user suggests that the code provided is not good and provides a link for better code. The solution is to check the provided link for better code examples.
safwan
15 Jun, 2023, 16:17

ah wait. are you using the server sdk?

Bouahaza
15 Jun, 2023, 16:17
anyuru
15 Jun, 2023, 16:20

Yes I am using the server SDK to create the initial project configuration. Create collections and dummy users, and collections for my opensource project

anyuru
15 Jun, 2023, 16:20

So that's what they run when they've just cloned the project

safwan
15 Jun, 2023, 16:21

Have you set the environment variables for the function?

anyuru
15 Jun, 2023, 16:21

Yes.

safwan
15 Jun, 2023, 16:22

Can you show? Just to be sure.

safwan
15 Jun, 2023, 16:22

Feel free to hide any important variables

anyuru
15 Jun, 2023, 16:22

API_KEY=your-api-key PROJECT_ID=your-project-id PROJECT_ENDPOINT=your-project-endpoint REDIRECT_URL=your-redirect-url

anyuru
15 Jun, 2023, 16:22

They appear in that format

Bouahaza
15 Jun, 2023, 16:22

I suppose you try to fork this repo : https://github.com/davidofug/distributa ?

anyuru
15 Jun, 2023, 16:23

That's the project I'm contributing to

Bouahaza
15 Jun, 2023, 16:24

PROJECT_ENDPOINT=your-project-endpoint

Here you need

PROJECT_ENDPOINT=https://cloud.appwrite.io/v1

If you use cloud, or own appwrite instance URL

anyuru
15 Jun, 2023, 16:24

Do you know that's it's always the best practice not to expose environment variables.

anyuru
15 Jun, 2023, 16:25

I've already set these in my local environment

anyuru
15 Jun, 2023, 16:25

And I'm not ready to expose them here

Bouahaza
15 Jun, 2023, 16:27

Error msg on your screenshot suggest that you set api.appwrite.io

anyuru
15 Jun, 2023, 16:33

Alright let me try to debug

anyuru
15 Jun, 2023, 16:37

I can access the environment variables

anyuru
15 Jun, 2023, 16:37

I've confirmed

anyuru
15 Jun, 2023, 17:08

After some hefty debugging. I've finally figured it out. Thanks for your help.

safwan
16 Jun, 2023, 07:58

Could you please explain what the issue was?

It'll come in handy to other people who might fave a similar issue!

anyuru
16 Jun, 2023, 09:20

The code had no errors. I just started another project

anyuru
16 Jun, 2023, 09:20

In the cloud. But still doesn't work with the old project variables

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more