Unable to authenticate on development environment

Feature(s) impacted

Runing forest on local environment

Observed behavior

the server is running on my local but it is showing this error on forest:

Expected behavior

open forest on dev env

Failure Logs


I already added origins on app.js:

Context

  • Project name: clevermate
  • Environment name: Development
  • Agent technology: nodejs
  • Agent (forest package) name & version: v9
  • Database type: postgres

Hi @Adel_de_Clevermate ,

Did you change something recently on your configurations ?
Since when the issue is happening ?

Best regards,

Shohan

Hi @shohanr ,

No nothing changed on config related to this issue, I still got the same results.
(I tried an extension to allow cors origin but still having the same issue).
Did you have any insights about this?

Thank you.

Hi @Adel_de_Clevermate ,

Do you have this in your code :

// Support for request-private-network as the `cors` package
// doesn't support it by default
// See: https://github.com/expressjs/cors/issues/236
app.use((req, res, next) => {
  if (req.headers['access-control-request-private-network']) {
    res.setHeader('access-control-allow-private-network', 'true');
  }
  next(null);
});
app.use('/forest/authentication', cors({
  ...corsConfig,
  // The null origin is sent by browsers for redirected AJAX calls
  // we need to support this in authentication routes because OIDC
  // redirects to the callback route
  origin: corsConfig.origin.concat('null')
}));
app.use(cors(corsConfig));

?

@shohanr
Yes I do have this on app.js

..

const app = express();

let allowedOrigins = [/\.forestadmin\.com$/, /localhost:\d{4}$/, "localhost:3310", "https://app.forestadmin.com", "app.forestadmin.com"];

if (process.env.CORS_ORIGINS) {
  allowedOrigins = allowedOrigins.concat(process.env.CORS_ORIGINS.split(','));
}

const corsConfig = {
  origin: allowedOrigins,
  maxAge: 86400, // NOTICE: 1 day
  credentials: true,
};

app.use(morgan('tiny'));
// Support for request-private-network as the `cors` package
// doesn't support it by default
// See: https://github.com/expressjs/cors/issues/236
app.use((req, res, next) => {
  if (req.headers['access-control-request-private-network']) {
    res.setHeader('access-control-allow-private-network', 'true');
  }
  next(null);
});
app.use('/forest/authentication', cors({
  ...corsConfig,
  // The null origin is sent by browsers for redirected AJAX calls
  // we need to support this in authentication routes because OIDC
  // redirects to the callback route
  origin: corsConfig.origin.concat('null')
}));
app.use(cors(corsConfig));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use(jwt({
  ..
}));

app.use('/forest', (request, response, next) => {
  if (PUBLIC_ROUTES.includes(request.url)) {
    return next();
  }
  return ensureAuthenticated(request, response, next);
});

requireAll({
  dirname: path.join(__dirname, 'routes'),
  recursive: true,
  resolve: (Module) => app.use('/forest', Module),
});

requireAll({
  dirname: path.join(__dirname, 'middlewares'),
  recursive: true,
  resolve: (Module) => Module(app),
});

app.use(errorHandler());

module.exports = app;

Thanks. Could you please share your response headers ?

@shohanr
for the authentication call, the response headers are empty

@shohanr
I got this using Firefox:


I wonder if you got any idea about this ?
thank you

Hello @Adel_de_Clevermate,

It seems this is due to a new rule enforced by Chrome version 130, by default it will require a new header to be sent by the frontend to access private networks.

I will work on a fix and release it ASAP, letting you know when it is live.

In the meantime, you can disable by changing the configuration of your browser.
chrome://flags/#private-network-access-respect-preflight-results
chrome://flags/#private-network-access-ignore-worker-errors
chrome://flags/#private-network-access-ignore-navigation-errors

Best regards,

Hi @dogan.ay

the cros error seems to be gone now, but I still got this endpoint error :


image

any idea please?

thank you.

Could you try to clear the cache and hard refresh your page ?

Could I ask you to try with chrome on private navigation with all extensions disabled ? I sadly cannot reproduce your issue, I’m wondering if there is something else interacting with your chrome browser.

It is working now.

resolved SSL_PROTOCOL_ERROR, I replaced the http with https server, and disabled also this flag on chrome :
chrome://flags/#allow-insecure-localhost
This may be useful for others.

Thank you @dogan.ay @shohanr