# Authentication errors after migrating to v7

**URL:** <https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877>\
**Category:** Help me!\
**Created:** [July 12, 2021, 9:14am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877 "2021-07-12T09:14:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 12, 2021, 9:14am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/1 "2021-07-12T09:14:05Z")

</div>

This is a template you can use to report issues. You can also drag images, videos and include `Preformatted text`

```javascript
Hello :)
We cannot authenticate on our forestadmin project since upgrade to v7 .
Everything working fine in dev mod
I guess we are doing something wrong ... :(

Access to fetch at 'https://admin.production.panopli.co/forest/authentication' from origin 'https://app.forestadmin.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Request URL: https://admin.production.panopli.co/forest/authentication
Referrer Policy: strict-origin-when-cross-origin
Provisional headers are shown
Content-Type: application/json; charset=utf-8
Referer: https://app.forestadmin.com/
sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

Request URL: https://admin.production.panopli.co/forest/authentication
Request Method: OPTIONS
Status Code: 502 
Remote Address: 34.95.84.11:443
Referrer Policy: strict-origin-when-cross-origin
alt-svc: clear
content-length: 332
content-type: text/html; charset=UTF-8
date: Mon, 12 Jul 2021 09:09:47 GMT
referrer-policy: no-referrer
:authority: admin.production.panopli.co
:method: OPTIONS
:path: /forest/authentication
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
access-control-request-headers: content-type
access-control-request-method: POST
origin: https://app.forestadmin.com
referer: https://app.forestadmin.com/
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: cross-site
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

```

## Expected behavior

Please describe here the behavior you are expecting.

## Actual behavior

What is the current behavior?

## Failure Logs

Please include any relevant log snippets, if necessary.

## Context

Please provide any relevant information about your setup.

- Package Version: 7.8.3
- Express Version: 4.17.19
- Sequelize Version:
- Database Dialect: mongo
- Database Version:
- Project Name: Panopli

---

<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:** [July 12, 2021, 9:22am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/2 "2021-07-12T09:22:29Z")

</div>

Hello @Tom,

Thanks for your feedback!

Your browser is getting a 502 error for the request that it’s sending `OPTIONS https://admin.production.panopli.co/forest/authentication`

This request is the first one that is launched to your agent before anything else.

The 502 error indicates a “Bad gateway error”, meaning that your reverse proxy cannot access to your agent to redirect the request.

Can you first test if you can access this agent from your browser, at the addess `https://admin.production.panopli.com`? You should see " Your application is running!`. If it’s not the case, then I guess that something is wrong with your configuration.

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 12, 2021, 9:38am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/3 "2021-07-12T09:38:14Z")

</div>

Hello @GuillaumeGautreau 🙂  
Indeed the [admin.production.panopli.co](http://admin.production.panopli.co) isn’t accessible 🤔  
Everything was fine in dev mod, any clues on what could break ?

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 12, 2021, 10:20am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/4 "2021-07-12T10:20:53Z")

</div>

Well i got errors on my gcp container logs  
first i get flooded by  
PM2 error: (node:1) Warning: Accessing non-existent property ‘to’ of module exports inside circular dependency

then

2021-07-12T09:56:30: PM2 error: TypeError [ERR\_INVALID\_ARG\_TYPE]: The “data” argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1)

then i get the normal forestadmin logs

EDIT : well nevermind those logs also appears after we rolled back the migration , we can correctly log after rolled back

---

<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:** [July 12, 2021, 11:03am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/5 "2021-07-12T11:03:30Z")

</div>

Hello, a 502 error indicates one of the following:

- Either your agent is not running
- Or it’s listening on a port that is not the one you configured in nginx/apache

I tested again to access your agent, and I don’t have the same error. Do you have the same error when trying to login in?

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 12, 2021, 11:39am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/6 "2021-07-12T11:39:24Z")

</div>

I rolled back to v5 to make it work ( we have a very old project 😅 )  
The agent in v7 seems to init correctly as we get the welcome logs " Your admin panel is available here: [https://app.forestadmin.com/projects](https://app.forestadmin.com/projects)" on my container logger.  
Then i get 404 everytime i try to authenticate

---

<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:** [July 12, 2021, 12:16pm UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/7 "2021-07-12T12:16:04Z")

</div>

Do you have the 404 error with the v7 or v5?

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 12, 2021, 12:19pm UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/8 "2021-07-12T12:19:18Z")

</div>

The v5 is working fine, i log in no pb .

The 404 occurs with v7

---

<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:** [July 12, 2021, 12:42pm UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/9 "2021-07-12T12:42:39Z")

</div>

Ok, then the error is no more a 502 as it was at the beginning.

Now, I suppose that the `OPTIONS` request receives a valid response, but you get a 404 on `/forest/session`?

As you are modifying a production environment, you have to copy the file `forestadmin-schema` from the dev environment that you already migrated and that you validated.

This file contains a declaration of the version that is being used by the server, and this version is used to determine which endpoint to use when logging in (it changed in v7).

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 26, 2021, 9:01am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/10 "2021-07-26T09:01:35Z")

</div>

Hello , i apologize i was on holiday :slight\_smile  
We did not receive any OPTIONS .  
Here’s my container logs wen i’m building the app

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

The 502 from [admin.production.panopli.co](http://admin.production.panopli.co) is from our load balancer ( it cannot find any healthy pod ).  
I have no clue on what is going on . The V7 upgrade works fine on localhost, no error message and i can use the app.

---

<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:** [July 26, 2021, 9:39am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/11 "2021-07-26T09:39:46Z")

</div>

Hello @Tom,

Can you open the developer tools in your browser, select the network tab and try to login to your agent?

Then, please share with us the details about the queries that are failing (request & response headers and content).

Thanks

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 26, 2021, 10:08am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/12 "2021-07-26T10:08:04Z")

</div>

Hello @GuillaumeGautreau 🙂

```javascript
Documentlocalhost	
1 requests
465 B transferred
139 B resources
Finish: 13 ms
DOMContentLoaded: 260 ms
Load: 259 ms
Request URL: http://localhost:3000/
Request Method: GET
Status Code: 404 Not Found
Remote Address: [::1]:3000
Referrer Policy: strict-origin-when-cross-origin
Access-Control-Allow-Credentials: true
Connection: keep-alive
Content-Length: 139
Content-Security-Policy: default-src 'none'
Content-Type: text/html; charset=utf-8
Date: Mon, 26 Jul 2021 10:04:47 GMT
Keep-Alive: timeout=5
Vary: Origin
X-Content-Type-Options: nosniff
X-Powered-By: Express
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Cookie: _ga=GA1.1.2064795909.1594195069; nQ_cookieId=da041558-f2e1-15df-86f6-33055be93573; _scid=33b89df8-5876-456f-9779-f8f571edbf50; intercom-session-hf6w2yvr=ZmZBcThqNjI1R2ZVaE9iOXZPbnpmV1h0NE04WmtrR1V1cW80Z3J6c3F2aEpiZE9jYzZDNmpUeThDRG5RNUlNVy0tOEtZaWh4M1J3aDNxakRJUlF2b0JFUT09--39d1dc3c2423671b40c04555930543e1cdb8d4d0
Host: localhost:3000
sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"
sec-ch-ua-mobile: ?0
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

```

And the response

Error
```
Cannot GET /
```

---

<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:** [July 26, 2021, 11:45am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/13 "2021-07-26T11:45:12Z")

</div>

Hello @Tom,

Did you create a new application targetting MongoDB, or did you add the `forestadmin-mongoose` package to an existing app?

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [July 26, 2021, 3:02pm UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/14 "2021-07-26T15:02:37Z")

</div>

I’m not sure of what you’r asking me .  
We have an “old” project ( i guess we start on V2 ) . We are currently on V5 ( i rolled back the V7 update )

---

<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:** [July 26, 2021, 3:06pm UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/15 "2021-07-26T15:06:46Z")

</div>

Ok, then the route `/` is probably not defined on the backend. As you get a 404 error, it means that a backend is correctly responding.

Now, let’s move on to the next topic: authentication.

Can you please open the right environment on your project, in your browser, open the developer tools and identify the requests that are failing during the authentication?

---

<div class="post-metadata">

**Author:** ![Tom](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/tom/32/677_2.png) [@Tom](https://community.forestadmin.com/u/Tom)\
**Post date:** [August 4, 2021, 9:11am UTC](https://community.forestadmin.com/t/authentication-errors-after-migrating-to-v7/2877/16 "2021-08-04T09:11:57Z")

</div>

Hello again 🙂 Sorry for late response . Thank you for your help @GuillaumeGautreau , it was actually an healtcheck issue , we were trying on / and we get no reponses ( as it wasn’t define on the backend) . Changing the healtcheck url on our side solve the problem  
Have a nice day 🙂
