# Forest cannot authenticate the user for this request in prod and localhost

**URL:** <https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560>\
**Category:** Help me!\
**Created:** [August 14, 2023, 8:11pm UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560 "2023-08-14T20:11:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehdi\_Marouani](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mehdi_marouani/32/6371_2.png) [@Mehdi\_Marouani](https://community.forestadmin.com/u/Mehdi_Marouani)\
**Post date:** [August 14, 2023, 8:11pm UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560/1 "2023-08-14T20:11:44Z")

</div>

## Feature(s) impacted

I can’t access any of the generated routes (e.g forest/authentication, forest/user) - in nodejs project

## Observed behavior

“{“errors”:[{“status”:401,“detail”:“Forest cannot authenticate the user for this request.”,“name”:“Unauthorized”}]}”

## Expected behavior

I expect to receive a JSON response

## Context

- Project name: EdityourFilm
- Team name: Operations
- Environment name: localhost / production
- Agent (forest package) name & version: I’m using agent version 8.5.15
- Database type: postgres
- Recent changes made on your end if any: no, I just generated the project using forest-cli command, I didn’t edit anything yet

---

<div class="post-metadata">

**Author:** ![shohanr](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shohanr/32/4999_2.png) [@shohanr](https://community.forestadmin.com/u/shohanr)\
**Post date:** [August 16, 2023, 8:38am UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560/2 "2023-08-16T08:38:52Z")

</div>

Hi @Mehdi_Marouani and welcome to our community !

I am not sure to see what you were expecting by a 'JSON response".  
Could you please reformulate what you were trying to do?

Best regards,

Shohan

---

<div class="post-metadata">

**Author:** ![Mehdi\_Marouani](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mehdi_marouani/32/6371_2.png) [@Mehdi\_Marouani](https://community.forestadmin.com/u/Mehdi_Marouani)\
**Post date:** [August 16, 2023, 12:21pm UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560/4 "2023-08-16T12:21:28Z")

</div>

Hi Shohan,

I’m still new to forest admin, and I just set up a project that connects to a Postgres database that has one table (“user” table).  
I see that some folders are generated (/middleware, /routes, etc), and the routes are generated with CRUD functions (List, delete, update, etc.), so I tried to access the list of “users” (from the database) in my localhost “[http://localhost:3310/forest/user](http://localhost:3310/forest/user)” and I got the error message mentioned above.

The idea of using admin forest is to give the ability to some users to manage data (on [https://app.forestadmin.com/](https://app.forestadmin.com/)) and also expose some API to be consumed by our website (e.g list of users)

---

<div class="post-metadata">

**Author:** ![shohanr](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shohanr/32/4999_2.png) [@shohanr](https://community.forestadmin.com/u/shohanr)\
**Post date:** [August 17, 2023, 7:56am UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560/5 "2023-08-17T07:56:06Z")

</div>

To use this endpoint you will have to use an authentification token.  
[Here is a thread](https://community.forestadmin.com/t/request-failed-with-status-code-403-in-test-environment/3648/3) explaining how you could do it.

Best regards,

Shohan

---

<div class="post-metadata">

**Author:** ![shohanr](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shohanr/32/4999_2.png) [@shohanr](https://community.forestadmin.com/u/shohanr)\
**Post date:** [August 17, 2023, 10:23am UTC](https://community.forestadmin.com/t/forest-cannot-authenticate-the-user-for-this-request-in-prod-and-localhost/6560/6 "2023-08-17T10:23:05Z")

</div>

I just want to add that, even though it is technically possible, exposing the API to be consumed by external applications is not a feature supported or promoted. Support on this part will not be proposed by our side.

Best regards,

Shohan
