Unauthorized app / [object Object]

Data in forest admin not working!

Upgrading to v7. Got the forest_client_id. Working fine locally. Deploying to heroku.

Actual behavior

401 when loading the app. The app only responds [object Object]
500 in forest itself

Failure Logs

Context

  • Package Version: 7.2.2
  • Express Version: 4.17
  • Sequelize Version:
  • Database Dialect: pg
  • Database Version: 8.5.1
  • Project Name: carl-forest

Hi @Antoine007,

Thank you for sharing your issue with us.

Could you confirm that your staging environment contains an APPLICATION_URL entry set with your remote environment URL? (https://carl-forest-staging.herokuapp.com)

Yes sir!
Screenshot 2021-03-23 at 16.49.05|634x238

Could you also try to log out and log back in again?

Also when you say that your The app only responds [object Object] what do you mean exactly?

Last thing that could help would be a screen record of your experience trying to access the project (using Loom for example)

Logging out does nothing.
[object Object] is the reposne when I query the node app from the browser (the url that forest queries to get the data and gets a 500 on)

Does this work?

It works well @Antoine007, thank you.

It looks like that the calls from the frontend to your staging API is returning a 500 error, can you share with me the content of the answer (and there should probably be error logs on your API server related to this 500 error).

Thank you

the errors are the ones in the first post + this

I have env DATABASE_REJECT_UNAUTHORIZED and DATABASE_SSL = true. Is that right?

Hello @Antoine007,

The logs say that the agent is refusing to connect to your database because of the error DEPTH_ZERO_SELF_SIGNED_CERT which indicates that your DB uses a self-signed certificate that cannot be validated.

If it’s normal and if you don’t plan to use a properly signed certificate, you can set the option DATABASE_REJECT_UNAUTHORIZED to false.

In this case, it will not reject (thus it will accept) invalid certificates.

toggling it doesn’t fix it. Same error.
I have

if (
  process.env.DATABASE_SSL &&
  JSON.parse(process.env.DATABASE_SSL.toLowerCase())
) {
  if (process.env.DATABASE_REJECT_UNAUTHORIZED === false) {
    databaseOptions.dialectOptions.ssl = {
      rejectUnauthorized: false,
      require: true,
    };
  } else {
    databaseOptions.dialectOptions.ssl = true;
  }
}

in the models/index.js Is that right?

Hi @Antoine007,

Can you try to change this code into

// Add quotes around false here, because env variables
// are strings
if (process.env.DATABASE_REJECT_UNAUTHORIZED === "false") {
    databaseOptions.dialectOptions.ssl = {
      rejectUnauthorized: false,
      require: true,
    };
  } else {
    databaseOptions.dialectOptions.ssl = true;
  }

To test if it works better?

This generated code has been changed in more recent versions of lumber to address this issue, but your project seem to have been generated with an older version of lumber.

2 Likes

Thanks, that did it.

1 Like