# Stuck on production environment configuration

**URL:** <https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191>\
**Category:** Help me!\
**Tags:** setup\
**Created:** [September 1, 2021, 6:35pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191 "2021-09-01T18:35:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 1, 2021, 6:35pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/1 "2021-09-01T18:35:02Z")

</div>

Hello, can’t deploy production env - stuck on ` Waiting for your environment variables to be correctly set. If this error persists, please check your server logs.`

## Failure Logs

```javascript
> blend-forestadmin@0.0.1 start /usr/src/app
> node ./server.js

Your application is listening on port 3310.
[forest] 🌳🌳🌳 The .forestadmin-schema.json file does not exist.
{}
[forest] 🌳🌳🌳 The schema cannot be synchronized with Forest Admin servers.
{}
Your admin panel is available here: https://app.forestadmin.com/projects
GET /forest 204 - - 8.992 ms
GET /forest 204 - - 1.087 ms
GET /forest 204 - - 0.885 ms
GET /forest 204 - - 0.740 ms
GET /forest 204 - - 0.847 ms
GET /forest 204 - - 0.780 ms

```

## Context

running in kubernetes

- Database Dialect: mongodb
- Database Version: 4.4
- Project Name: blend-forestadmin

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 1, 2021, 6:37pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/2 "2021-09-01T18:37:25Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/1/117591df9e4b3ed935c312c6b30c28e6d805fde8.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/7/7b4ba037547ab7b9661f71148328d2defbe89663.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/c/c4ff0129419dd4e5fabb6f35790777561d0d488f.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/ab0dfc92956d758451c1db5cb739f8bbbe8ebcae.png)

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 1, 2021, 6:41pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/3 "2021-09-01T18:41:56Z")

</div>

Seems like OPTIONS request is the issue - saw it on my dev env which is local.

I see OPTIONS requests in ingress-controller with status code 204 but i don’t see them inside forestadmin logs.

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 1, 2021, 6:44pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/4 "2021-09-01T18:44:37Z")

</div>

Do forestadmin use websockets?

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 2, 2021, 8:08am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/5 "2021-09-02T08:08:18Z")

</div>

Hey @shdwraze 👋

Could you share:

- Your CORS configuration
- The type of onboarding method you used (In-app or forest-cli project generation)

Your logs seems to indicate that you don’t have a `.forestadmin-schema.json` on your project startup, which is most likely the issue here. (You should have this file in dev - and it should be versionned in your VCS)

The code you deploy using `forest-express-mongoose` will not use websocket.

Let me know

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 2, 2021, 4:02pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/6 "2021-09-02T16:02:57Z")

</div>

Hi @anon39848301 , here CORS

```javascript
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-origin: "*"
    nginx.ingress.kubernetes.io/cors-allow-headers: "*"
    nginx.ingress.kubernetes.io/cors-allow-methods: "*"
    nginx.ingress.kubernetes.io/cors-allow-credentials: "true"

```

I use forest-cli project generation. What is in-app method?

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 2, 2021, 4:09pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/7 "2021-09-02T16:09:33Z")

</div>

About `.forestadmin-schema.json` i’ve tried to deploy app in kubernetes with node\_env=production but got this error so I switched to development env - seems bad idea.

Can’t realize how to deploy forestadmin in production env on kubernetes, is it even possible without pain?)

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 2, 2021, 4:12pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/8 "2021-09-02T16:12:31Z")

</div>

With `NODE_ENV=devleopment` i have no errors in logs but i got this in admin panel:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/2/28c2e796f58b597dbcad0a3198249e28e41ecce4.png)

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 2, 2021, 4:22pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/9 "2021-09-02T16:22:31Z")

</div>

And yes `.forestadmin-schema.json` under our VCS and in docker image which deployed. But when I’m switching to `NODE_ENV=production` forestadmin throws errors in log that he can’t find this file.

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 2, 2021, 6:01pm UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/10 "2021-09-02T18:01:46Z")

</div>

I’ve finished production environment setup but it’s working only with `NODE\_ENV=development" and on standalone instance + docker setup.

What could I miss?

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 3, 2021, 7:10am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/11 "2021-09-03T07:10:06Z")

</div>

Ok, let’s investigate this.

Could you make sure that:

- `FOREST_ENV_SECRET`, `APPLICATION_URL` & `NODE_ENV` have the correct value in production.
  - In production, `NODE_ENV` should be `production`. This is required to avoid regenerating a `.forestadmin-schema.json` in production. This file should only be updated in a development environment.
  - `APPLICATION_URL` is used for the login step, which is the one that seems failing in your case
  - `FOREST_ENV_SECRET` must be at the value displayed in the `Deploy to production` screen.

In order to debug this step, I would highly suggest to `console.log(process.env)` on server startup. We have a lot of thread on the community having a similar issues that only has one of these 3 variables not set or incorrectly set.

- Make sure that you have a `.forestadmin-schema.json` in your docker image. When your backend starts with `NODE_ENV=production`, this file will not be regenerated and it is required to setup a production environment. Some docker version have known issues with `.`/hidden files, especially at build time.

- Try to access your production URL and make sure that you are seeing the “Your application is running” message

> I use forest-cli project generation. What is in-app method?

`in-app` method uses an existing application to plug forest. Using the `forest-cli` setup, we generate a backend for you.

> Can’t realize how to deploy forestadmin in production env on kubernetes, is it even possible without pain?)

It is possible indeed. I would highly suggest to test your docker image locally though, just to check if the deployment fails because of a k8s misconfiguration - or simply because of missing files in your docker image.

> With `NODE_ENV=devleopment` i have no errors in logs but i got this in admin panel:

Please don’t put `NODE_ENV=development` in a production environment. This will definitely cause issues related to authentication, schema generation, etc…

After you validate the points below, if you are still experiencing the issue mentionned [here](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/8), you should have errors in your browser console. These errors will be helpful to assist you in the deploy to production process.

Let me know if that helps.

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 3, 2021, 7:30am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/12 "2021-09-03T07:30:59Z")

</div>

Hi, all variables are same from `console.log(process.env)` and in production. `.forestadmin-schema.json` inside docker image but backend see this file only if `NODE_ENV=development` - i can’t make backend work with `production`.

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 3, 2021, 7:37am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/13 "2021-09-03T07:37:57Z")

</div>

Do you have any errors in your browser console?

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 3, 2021, 7:39am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/14 "2021-09-03T07:39:52Z")

</div>

Nope. Just missing `.forest-schema.json`/can’t send schema to forestadmin servers in backend logs on startup.

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 3, 2021, 7:48am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/15 "2021-09-03T07:48:45Z")

</div>

I just looked at the code responsible of this error message, and the error is clear to me - our package can’t locate any `.forestadmin-schema.json` in your project on production.  
Our server should receive this file in order to allow the project to be deployed in production, and there are no call to our API expect the one you may have done using `NODE_ENV=development` in production.

If a `docker ls` clearly show that the file exists, you may be using the `schemaDir` option with an incorrect value in your forest `.init()` method.

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 3, 2021, 7:54am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/16 "2021-09-03T07:54:15Z")

</div>

```javascript
drwxrwxr-x 9 ubuntu ubuntu 4096 Sep 2 17:57 .
drwxrwxr-x 4 ubuntu ubuntu 4096 Sep 2 16:46 ..
-rw-rw-r-- 1 ubuntu ubuntu 32 Sep 2 16:46 .dockerignore
-rw-rw-r-- 1 ubuntu ubuntu 452 Sep 2 17:57 .env
-rw-rw-r-- 1 ubuntu ubuntu 53032 Sep 2 16:46 .forestadmin-schema.json
-rw-rw-r-- 1 ubuntu ubuntu 28 Sep 2 16:46 .gitignore
-rw-rw-r-- 1 ubuntu ubuntu 246 Sep 2 16:46 Dockerfile
-rw-rw-r-- 1 ubuntu ubuntu 1803 Sep 2 16:46 app.js
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 config
-rw-rw-r-- 1 ubuntu ubuntu 507 Sep 2 16:46 docker-compose.yml
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 forest
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 middlewares
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 models
-rw-rw-r-- 1 ubuntu ubuntu 73182 Sep 2 16:46 package-lock.json
-rw-rw-r-- 1 ubuntu ubuntu 474 Sep 2 16:46 package.json
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 public
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 routes
-rw-rw-r-- 1 ubuntu ubuntu 1281 Sep 2 16:46 server.js
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 2 16:46 views

```

If i will restart backend with `NODE_ENV=production` I’ll get errors about missing `.forestadmin-schema.json`. How can I use incorrect `schemaDir` option if it’s default? Where I need to watch and how to fix?

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 3, 2021, 8:00am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/17 "2021-09-03T08:00:22Z")

</div>

Is this from your K8S pod? Or your local machine?

In a default configuration using a project generated with `forest-cli`, you should not have anything to do with `schemaDir`. I’m just pointing this out since it is the only reason where you may experience the error you are mentioning. We trigger the `The .forestadmin-schema.json file does not exist.` using the `ENOENT` error of `fs.readFileSync` on the exact same path you should run your `node ./server.js` - So I can’t spot any other sources that can trigger this error except for the fact that `.forestadmin-schema.json` does not exist.

Did you modify anything on the generated project?

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 3, 2021, 8:05am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/18 "2021-09-03T08:05:50Z")

</div>

> [@shdwraze](#):
>
> I’ve finished production environment setup but it’s working only with `NODE\_ENV=development" and on standalone instance + docker setup.

I didn’t modify anything.

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [September 3, 2021, 8:15am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/19 "2021-09-03T08:15:42Z")

</div>

> [@anon39848301](#):
>
> Is this from your K8S pod? Or your local machine?

I need to know from where the previous output you shared comes from in order to help.

The fact that it works with `NODE_ENV=development` indicate that the regeneration of the `.forestadmin-schema.json` file makes it work though.

---

<div class="post-metadata">

**Author:** ![shdwraze](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shdwraze/32/2990_2.png) [@shdwraze](https://community.forestadmin.com/u/shdwraze)\
**Post date:** [September 3, 2021, 8:28am UTC](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191/20 "2021-09-03T08:28:21Z")

</div>

Production deployed on standalone instance inside docker as I said.

[Next page](https://community.forestadmin.com/t/stuck-on-production-environment-configuration/3191.md?page=2)
