# Problems integrating into existing server running Express/Sequelize

**URL:** <https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518>\
**Category:** Help me!\
**Tags:** howtos, setup\
**Created:** [May 18, 2021, 12:59pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518 "2021-05-18T12:59:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 12:59pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/1 "2021-05-18T12:59:45Z")

</div>

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.

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

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

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

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

Here is my initilization code:

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

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 1:11pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/2 "2021-05-18T13:11:54Z")

</div>

Hello @Wolfie, welcome in the community 🥳

It seems that you need to change

```javascript
objectMapping: db.sequelize

```

Into

```javascript
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.

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 1:22pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/3 "2021-05-18T13:22:18Z")

</div>

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

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

Though the secrets are infact correct

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 1:24pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/4 "2021-05-18T13:24:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 1:31pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/5 "2021-05-18T13:31:02Z")

</div>

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

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

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

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 1:38pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/6 "2021-05-18T13:38:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 1:56pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/7 "2021-05-18T13:56:14Z")

</div>

> [@GuillaumeGautreau](#):
>
> your dev tools and try to login again?

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

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

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

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 2:00pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/8 "2021-05-18T14:00:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 2:46pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/9 "2021-05-18T14:46:13Z")

</div>

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

But I’m still getting this:

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 2:47pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/10 "2021-05-18T14:47:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 18, 2021, 3:09pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/11 "2021-05-18T15:09:06Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 18, 2021, 3:45pm UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/12 "2021-05-18T15:45:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 19, 2021, 7:06am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/13 "2021-05-19T07:06:46Z")

</div>

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

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

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

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [May 19, 2021, 7:10am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/14 "2021-05-19T07:10:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 19, 2021, 7:12am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/15 "2021-05-19T07:12:48Z")

</div>

> [@GuillaumeGautreau](#):
>
> Make sure that the path is correct and that the directory exists because `forest-express` will not create it for you.

@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) ?

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 19, 2021, 7:44am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/16 "2021-05-19T07:44:21Z")

</div>

@GuillaumeGautreau

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

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

Could i check if the secrets are matching somehow?

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

---

<div class="post-metadata">

**Author:** ![anon16419211](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anon16419211](https://community.forestadmin.com/u/anon16419211)\
**Post date:** [May 19, 2021, 8:33am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/17 "2021-05-19T08:33:15Z")

</div>

> [@Wolfie](#):
>
> Tomussss

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

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 19, 2021, 8:34am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/18 "2021-05-19T08:34:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anon16419211](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anon16419211](https://community.forestadmin.com/u/anon16419211)\
**Post date:** [May 19, 2021, 8:42am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/19 "2021-05-19T08:42:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Wolfie](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/wolfie/32/2232_2.png) [@Wolfie](https://community.forestadmin.com/u/Wolfie)\
**Post date:** [May 19, 2021, 8:50am UTC](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518/20 "2021-05-19T08:50:21Z")

</div>

@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:

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

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

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

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

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

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/57b6cea0194824108969ac2fd88702dfc46ba8d5.jpeg)

[Next page](https://community.forestadmin.com/t/problems-integrating-into-existing-server-running-express-sequelize/2518.md?page=2)
