Problems integrating into existing server running Express/Sequelize

I was trying to run forest admin with my express server, and i did the setup step by step.
What i receive is this error.

The configs are fine, and it sees all the models, but there are similar errors for each one:

I’ve tried a bunch of solution but i can’t seem to find the root of the problem.

Here is my initilization code:

  • Package Version: forest-express-sequelize : 7.9.1
  • Express Version: 4.17.1
  • Sequelize Version: 5.21.13

Hello @Wolfie, welcome in the community :partying_face:

It seems that you need to change

objectMapping: db.sequelize

Into

objectMapping: db.Sequelize

If I take a look at projects that I recently created, the parameter ObjectMapping needs to get the class Sequelize and not the instance of it.

Oh wow, my bad. Now the errors seems to be resolved, but i am getting another one now :

Though the secrets are infact correct

Can you send me the 5 last characters of your env secret, and your project’s name? I’ll check that they are correct.

Also, could you add a console.log("Env secret", process.env.FOREST_ENV_SECRET) before the call to forest.init just to check that its value is correctly initialized?

@GuillaumeGautreau It seems to have connected after a few tries! Though now it’s stuck at validation:

I did ad a log before the initialization. Last 5 characters are : b9281, and the name is Tomussss

I can also see that it fetched one of my models correctly

Can you please open your dev tools and try to login again?

Then find the query that is failing and share its details with us. It’ll help a lot finding the source of the error.

@GuillaumeGautreau
Tried it, here’s what i’m getting:

I also added the route to cors, though it doesn’t seem to go through:

Yes, because the regexp that you’re using to configure this middleware does not match the actual path:

  • Regex: ^(?!forest/?$).*
  • Path: admin/forest/authentication

These cors are handled by forest-express I guess.

Now, the more problematic thing I can see with your configuration, is that it seems that the current version of forest-express-sequelize does not support well being used as a sub-path of your api.

Can you check if you can simply use the route /forest instead of /admin/forest? Is it something possible in your case?

For information, all routes handled by forest-express-sequelize are already under the /forest prefix.

Sorry for taking so long, I did change the landing url, now it’s simply : https://server2.timespex.com/

But I’m still getting this:

Can you please copy/paste the details of the OPTIONS request that is sent just before the one that is failing because of CORS?

Request and response headers will contain the root cause of this error.

@GuillaumeGautreau I’ve managed to get it past CORS, but i think it just times-out now:

Then it’s the origin of your issue.

In order to work, these requests must have an answer. There is probably a problem with the configuration of your server regarding how these requests are handled.

Do you have any logs on the server side?

@GuillaumeGautreau I also have this message on the server side.

image

I have a hard time understanding what should our server do after initialization of forest. Should the route /forest/authentication/ return something from our server? Or should forest generate the appropriate routes? Sorry for the taking so long and thank you for the help so far

This error message is related to the place where the agent will save the file forestadmin-schema.json. Make sure that the path is correct and that the directory exists because forest-express will not create it for you.

I don’t know if it’s related to your problem, but it might worth trying to solve this error first, just in case.

@GuillaumeGautreau

I created the directory, so the error went away, but it’s still not going through. I also tried to stub the route /forest/authentication so that it returns a 204 status code, but still no luck. Should the route /forest/authentication/ be handled somehow manually on the server (guess that’s a dumb question, as it should return something) ?

@GuillaumeGautreau

We rebuilt the docker container, in hopes that maybe some data was cached. Now this error appeared again:

Could i check if the secrets are matching somehow?

EDIT: I found the env secret, they seem to be matching

Hello @Wolfie, I can’t see any project with this name, can you confirm it is your project name ?

Hey, i changed it midway, it’s now ‘timespex’ @lclisson

Ok what I can tell you on our side is:

  • We have an apimap for your project
  • We have a secret key

Have you been able to log in once on your project?
What is the step you are stuck on right now?
Are the FOREST_ENV_SECRET and FOREST_AUTH_SECRET well defined in your .env file?

@lclisson The secrets are defined correctly, and passed to the init method. The step i’m stuck on right now is, as mentioned before, the authentication process:

I am logged in and I do see that forest got hold of one of the tables. The auth process fails with this:

We are also using a reverse proxy with nginx for this, could this be the problem? Here is the config: