Redirect_uri always return http://localhost:3310 on authentication callback

Feature(s) impacted

Integration of forest-admin with FetherJs project

Observed behavior

Created app on forest-admin and give proper base URL. But on callback from authentication(https://backendapi.greenswanlab.com/forest/authentication) in the response ({“authorizationUrl”:“https://api.forestadmin.com/oidc/auth?client_id=encrypted-client-id&scope=openid%20email%20profile&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3310%2Fforest%2Fauthentication%2Fcallback&state={“renderingId”%3A194275}”}) the redirect_uri always set to “http://localhost:3310”.

From some resarch seen about a cache-issue on forest admin. Is this related to that.

Expected behavior

redirect_uri should be the base_url given on the time of app creation

Failure Logs

{“authorizationUrl”:“https://api.forestadmin.com/oidc/auth?client_id=encrypted-client-id&scope=openid%20email%20profile&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3310%2Fforest%2Fauthentication%2Fcallback&state={“renderingId”%3A194275}”}

Context

  • Project name: GSL-staging
  • Team name: Operations
  • Environment name: Production
  • Agent (forest package) name & version: “@forestadmin/agent”: “^1.8.4”,
  • Database type: Mongodb ( “@forestadmin/datasource-mongoose”: “^1.3.2”, )
  • Recent changes made on your end if any: …

Hello @Sawfish_Developers,

This issue is not related to cache. For your forest-express-mongoose agent, the redirect_uri should be defined with the help of an environment variable APPLICATION_URL, could you please check that this environment variable is set properly ?

Best regards,

done this. But not working still same
FOREST_ENV_SECRET=
FOREST_AUTH_SECRET=
FOREST_AGENT_URL=https://backendapi.greenswanlab.com
NODE_ENV=production
APPLICATION_URL=https://backendapi.greenswanlab.com

used forestAdmin framework.

to init the forest-admin used the below code snipet


import Liana, { ensureAuthenticated, PUBLIC_ROUTES } from “forest-express-mongoose”;
export default async function forestAdmin(app: Application) {
const connection = app.get(“mongooseClient”);
const forestConfig = app.get(“forestAdmin”);

const liana = await Liana.init({
configDir: path.join(__dirname, ‘/forest’),
envSecret: forestConfig.envSecret,
authSecret: forestConfig.authSecret,
schemaDir: process.env.FOREST_SCHEMA_DIR,
objectMapping: Mongoose,
connections: {
default: connection
}
});

}

tried to add applicationurl on Lian init also.

src/forest-admin.ts:31:5 - error TS2345: Argument of type ‘{ configDir: string; envSecret: any; authSecret: any; schemaDir: string | undefined; objectMapping: typeof Mongoose; connections: { default: any; }; applicationUrl: string; }’ is not assignable to parameter of type ‘LianaOptions’.
Object literal may only specify known properties, and ‘applicationUrl’ does not exist in type ‘LianaOptions’.

31 applicationUrl: ‘https://backendapi.greenswanlab.com’,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But got this error

Is there anything need to do on server. Installed forect-cli. Login to my account.
Anything else?

I am trying to reproduce the issue but to no avail.

As for the Liana init configuration, there should be nothing to change, the APPLICATION_URL is fetched directly from environment variables.

While looking at your project I can see that you have multiple other project pointing to the same api endpoint url moreover some of the environments from those projects are still using localhost:3310 as their endpoint. I also checked the call made to our backend for the authentication and I cannot see any call that was made in the last week for the 3 environments present in GSL-staging. Is it possible that the agent on your backend is not using the environment variables for your GSL-staging’s environments ?

created 3 environments. On creation mentioned the correct URL ( which I needed), not localhost:3310.

On your code snippet defining your liana, I cannot see any import of the dotenv. Maybe it is defined where you are using the function but can you confirm that you do import it ?
For JS:

require('dotenv').config();

For TS:

import 'dotenv/config';

Could you also send me in private the client_id you have removed from the authorizationUrl sent back by the agent on the authentication call ?

hi,

resolved the redirect_uri issue and opened the issue on git from personal email.

Now I face issue with invalid data fetch

Could you share your CORS configuration here pls ?

what kind of configuration you need? like nginx or something else(like defined on application )

I would need the configuration of any reverse proxy ahead of your application and the configuration defined for your application as well.