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
> 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
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.
Do forestadmin use websockets?
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
Hi @jeffladiray , here CORS
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?
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?)
With NODE_ENV=devleopment
i have no errors in logs but i got this in admin panel:
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.
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?
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, 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.
1 Like
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
.
Do you have any errors in your browser console?
Nope. Just missing .forest-schema.json
/can’t send schema to forestadmin servers in backend logs on startup.
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.
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?
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?
I didn’t modify anything.
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.
1 Like
Production deployed on standalone instance inside docker as I said.