Unable to authenticate / Error connection closed Rails

Hello after a year since i last updated it, i tried to log into my project as every days. But it’s not working anymore, i tried to upgrade to the last version of the gem for rails, but it’s still not working…

I get net::ERR_CONNECTION_CLOSED in the console as you will see into the below screenshots

Failure Logs



Context

My CORS config :



    config.middleware.insert_before 0, Rack::Cors do
      allow do
        hostnames = [null_regex, 'localhost:4200', 'app.forestadmin.com', 'localhost:3001']
        hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']

        origins hostnames
        resource '*',
                 headers: :any,
                 methods: %i[get post options delete put],
                 max_age: 0,
                 expose: [ 'Content-Disposition'],
                 credentials: true
      end
    end

Forest_liana.rb the 3 are called on the os level for sure

ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
ForestLiana.application_url = Rails.application.secrets.forest_application_url

Forest rails gem version => 6.0.3

I you need more informations, feel free to ask.

Thanks for you help

Hey @Joe_Marc,

We recently had a few instabilities on the platform. May I ask you to try again now, and tell me if you are experiencing any issue?
Also, did you follow the upgrade to v6 note available here?

If possible, could you also share your project name?

Thanks in advance :pray:

1 Like

Hey @jeffladiray

Thanks for your answer. I’ve tried again, and it’s still not working … :confused: ( still the same errors)

Yes i followed the steps of the updates except the static client id because i don’t think i need it ( maybe i’m wrong)

Project name is MonsieurJeanAdmin

Thanks in advance

Hello @Joe_Marc,

I think there is an extra point at the end of the remote address you configured for your remote environment. Forest Admin is trying to contact https://api-staging.waiter.fr./forest/authentication which does not look like a valid URL.

Can you change the configuration of this remote environment and fix the URL?

1 Like

Thanks for your response @GuillaumeGautreau ,
I had an error about the url indeed with . at the end of my domain.
But it does not update i still get the same error …

I made the change directly in our system, the extra dot was still present.

Can you refresh your browser and test again?

1 Like

Thanks for the update, i have the same error but without the dot now !
https://api-staging.waiter.fr/forest/authentification

I don’t really understand it since i don’t manage the endpoints /forest

My backend works fine at https://api-staging.waiter.fr

Can you share the detail about the new error?

  • Which HTTP requests are failing?
  • Can you share details about these requests & received response?

Yes here is the error in the console :

And here are the lgos of the received response :

The registration to the authentication API failed, response: {\"error\":\"invalid_redirect_uri\",\"error_description\":\"Redirect uris must be an array of valid urls. Received: \\\"\\\".\"}

Ok, thanks for sharing this error.

It seems that there is an error with the secret named forest_application_url. Can you check that its value is correctly configured with https://api-staging.waiter.fr in yout secrets.yml?

Hello,

Yes the value is configured in the vars of heroku as i always do.


The error you received indicates that this value was not correctly loaded by the application. Can you check that your application correctly receives this value, and uses it?

In the file config/initializers/forest_liana.rb you should have these 3 lines:

ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
ForestLiana.application_url = Rails.application.secrets.forest_application_url

Yes i have them :slight_smile:

Do you have a way to log the value that is set to ForestLiana.application_url? I’d like to be sure that the value is correct, because the error that is returned by the server clearly indicates that the string received is \"\"

I just logged it from heroku and i get the value.
Yes in the network response of the server the value is empty … i don’t understand why

The registration to the authentication API failed, response: {\"error\":\"invalid_redirect_uri\",\"error_description\":\"Redirect uris must be an array of valid urls. Received: \\\"\\\".\"}"

ok, here you retrieved the environment variable set on heroku.

I would like to be sure that the application itself and the liana is using the right value. I would like to be sure that ForestLiana.application_url is really equal to this value.

In addition to that, I find it strange that the value that is logged here is not exactly the same than the one you shared before: there is an extra slash at the end.

Yes because i tried to update it ( sorry for not mentionning it )

Can you find a way to log the value of ForestLiana.application_url and check that its value is correct?

For now i’m trying to find a way to log the value :slight_smile:

If you use puts, I guess that the line should appear in logs on heroku (you can access them on the web interface, or with the CLI)