You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy the content and use that as password / secret key. And run that again to generate another secure key.
135
+
136
+
### Required Environment Variables
137
+
116
138
Set the `ENVIRONMENT`, by default `local` (for development), but when deploying to a server you would put something like `staging` or `production`:
117
139
118
140
```bash
@@ -125,21 +147,44 @@ Set the `DOMAIN`, by default `localhost` (for development), but when deploying y
125
147
export DOMAIN=fastapi-project.example.com
126
148
```
127
149
128
-
You can set several variables, like:
150
+
Set the `POSTGRES_PASSWORD` to something different than `changethis`:
151
+
152
+
```bash
153
+
export POSTGRES_PASSWORD="changethis"
154
+
```
155
+
156
+
Set the `SECRET_KEY`, used to sign tokens:
157
+
158
+
```bash
159
+
export SECRET_KEY="changethis"
160
+
```
161
+
162
+
Note: you can use the Python command above to generate a secure secret key.
163
+
164
+
Set the `FIRST_SUPER_USER_PASSWORD` to something different than `changethis`:
165
+
166
+
```bash
167
+
export FIRST_SUPERUSER_PASSWORD="changethis"
168
+
```
169
+
170
+
Set the `BACKEND_CORS_ORIGINS` to include your domain:
171
+
172
+
```bash
173
+
export BACKEND_CORS_ORIGINS="https://dashboard.${DOMAIN?Variable not set},https://api.${DOMAIN?Variable not set}"
174
+
```
175
+
176
+
You can set several other environment variables:
129
177
130
178
*`PROJECT_NAME`: The name of the project, used in the API for the docs and emails.
131
179
*`STACK_NAME`: The name of the stack used for Docker Compose labels and project name, this should be different for `staging`, `production`, etc. You could use the same domain replacing dots with dashes, e.g. `fastapi-project-example-com` and `staging-fastapi-project-example-com`.
132
180
*`BACKEND_CORS_ORIGINS`: A list of allowed CORS origins separated by commas.
133
-
*`SECRET_KEY`: The secret key for the FastAPI project, used to sign tokens.
134
181
*`FIRST_SUPERUSER`: The email of the first superuser, this superuser will be the one that can create new users.
135
-
*`FIRST_SUPERUSER_PASSWORD`: The password of the first superuser.
136
182
*`SMTP_HOST`: The SMTP server host to send emails, this would come from your email provider (E.g. Mailgun, Sparkpost, Sendgrid, etc).
137
183
*`SMTP_USER`: The SMTP server user to send emails.
138
184
*`SMTP_PASSWORD`: The SMTP server password to send emails.
139
185
*`EMAILS_FROM_EMAIL`: The email account to send emails from.
140
186
*`POSTGRES_SERVER`: The hostname of the PostgreSQL server. You can leave the default of `db`, provided by the same Docker Compose. You normally wouldn't need to change this unless you are using a third-party provider.
141
187
*`POSTGRES_PORT`: The port of the PostgreSQL server. You can leave the default. You normally wouldn't need to change this unless you are using a third-party provider.
142
-
*`POSTGRES_PASSWORD`: The Postgres password.
143
188
*`POSTGRES_USER`: The Postgres user, you can leave the default.
144
189
*`POSTGRES_DB`: The database name to use for this application. You can leave the default of `app`.
145
190
*`SENTRY_DSN`: The DSN for Sentry, if you are using it.
@@ -151,23 +196,13 @@ There are some environment variables only used by GitHub Actions that you can co
151
196
*`LATEST_CHANGES`: Used by the GitHub Action [latest-changes](https://github.com/tiangolo/latest-changes) to automatically add release notes based on the PRs merged. It's a personal access token, read the docs for details.
152
197
*`SMOKESHOW_AUTH_KEY`: Used to handle and publish the code coverage using [Smokeshow](https://github.com/samuelcolvin/smokeshow), follow their instructions to create a (free) Smokeshow key.
153
198
154
-
### Generate secret keys
155
-
156
-
Some environment variables in the `.env` file have a default value of `changethis`.
157
-
158
-
You have to change them with a secret key, to generate secret keys you can run the following command:
0 commit comments