Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the reason of env folder? #105

Open
alimoli opened this issue Dec 17, 2023 · 1 comment
Open

What is the reason of env folder? #105

alimoli opened this issue Dec 17, 2023 · 1 comment

Comments

@alimoli
Copy link

alimoli commented Dec 17, 2023

Feature Request

I am trying to understand what is the purpose of having an /env folder that emulates the configuration already present in Strapi.
Example of config/database.ts:

postgres: {
      connection: {
        connectionString: env('DATABASE_URL'),
        host: env('DATABASE_HOST', 'localhost'),
        port: env.int('DATABASE_PORT', 5432),
        database: env('DATABASE_NAME', 'strapi'),
        user: env('DATABASE_USERNAME', 'strapi'),
        password: env('DATABASE_PASSWORD', 'strapi'),
        ssl: env.bool('DATABASE_SSL', false) && {
          key: env('DATABASE_SSL_KEY', undefined),
          cert: env('DATABASE_SSL_CERT', undefined),
          ca: env('DATABASE_SSL_CA', undefined),
          capath: env('DATABASE_SSL_CAPATH', undefined),
          cipher: env('DATABASE_SSL_CIPHER', undefined),
          rejectUnauthorized: env.bool(
            'DATABASE_SSL_REJECT_UNAUTHORIZED',
            true
          ),
        },
        schema: env('DATABASE_SCHEMA', 'public'),
      },
      pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
    },

My env/database.ts:

export default ({env}) => ({
  connection: {
    client: 'postgres',
    connection: {
      host: env('DATABASE_HOST', undefined),
      port: env.int('DATABASE_PORT', undefined),
      database: env('DATABASE_NAME', undefined),
      user: env('DATABASE_USERNAME', undefined),
      password: env('DATABASE_PASSWORD', undefined),
      ssl: env.bool('DATABASE_SSL', false) && {
        rejectUnauthorized: false
      }
    }
  }
});

Another related question, how does it behave this plugin in case of plugins (f.e. cloudinary)?

@Eventyret
Copy link
Member

It's using the cold configuration of strapi and should be updated soon as I'm writing V2.
The idea with the old one was to overwrite the .env
More info found here https://docs.strapi.io/dev-docs/configurations/environment/#environment-configurations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants