Upgrading to V7 CORS issue on production

Hello,

Since we’ve upgraded to v7, we have a cors issue on production, we can not connect to forest admin.

Expected behavior

Be connected to forest admin

Actual behavior

Failure Logs



Context

app.use (require ('cors') ({
	origin: [
		'https://app.zack.eco',
		'http://134.209.194.88:8081',
		'http://134.209.194.88:3000',
		'http://134.209.194.88:3100',
		'http://206.81.19.54:8081',
		'http://app.forestadmin.com',
		'https://app.forestadmin.com',
		'http://future.forestadmin.com',
		'https://future.forestadmin.com',
		'https://hellozack.fr',
		'http://hub.hellozack.fr',
		'https://hub.hellozack.fr',
		'https://partners.hellozack.fr',
		'http://partners.hellozack.fr',
		'http://localhost:8081',
		'http://localhost:3000',
	],
	credentials: true
}))
let allowedOrigins = [/\.forestadmin\.com$/, /localhost:\d{4}$/];
if (process.env.CORS_ORIGINS) {
  allowedOrigins = allowedOrigins.concat(process.env.CORS_ORIGINS.split(','));
}
const corsConfig = {
  origin: allowedOrigins,
  allowedHeaders: ['Authorization', 'X-Requested-With', 'Content-Type'],
  maxAge: 86400, // NOTICE: 1 day
  credentials: true,
};
app.use('/forest/authentication', cors({
  ...corsConfig,
  origin: corsConfig.origin.concat('null')
}));

app.use(cors(corsConfig));

Thanks for your help

Hello @didouche,

Thanks for your feedback.

The login modal that you are seeing is not the one that is supposed to be displayed with the v7. It could indicate that your liana is not correctly sending its metadata to our server.

Could you please fill in all the info that is asked in the template for new topics in the help me section? It will help us a lot to identify the stack that you are using, and your project:

  • Package Version:
  • Express Version:
  • Sequelize Version:
  • Database Dialect:
  • Database Version:
  • Project Name:

In addition to this information, could you please indicate

  • if the backend is showing any error at startup
  • if you are running your production or development environment
  • what are your environment variables (you can obfuscate the secrets)

Thanks

Hello @GuillaumeGautreau ,

  • Package Version: 7.11.2,
  • Express Version: 4.17.1,
  • Sequelize Version: 5.15.2,
  • Database Dialect: postgres,
  • Project Name: ZACK
  • No error on startup
  • In Development, everything works fine, we have this issue only in production
  • What environment variables do you need ?
    I have: FOREST_ENV_SECRET, FOREST_AUTH_SECRET, APPLICATION_URL, APPLICATION_PORT, FOREST_CLIENT_ID

As far as I can see, the environment variable DISABLE_AUTO_SCHEMA_APPLY is not defined (this one is preventing the schema to be sent to Forest Admin).

Can you check your file .forestadmin-schema.json, and see if the version at the end of this file is correct?

I can see in the database that your previous version was forest-express-sequelize@4.0.2, is it correct? Did you follow the documentation to upgrade from every major version?

Right, in production our .forestadmin-schema.json has not the good liana version. How can we update it ?
But do you know why in development the file is set up correctly ?

This file is only updated automatically in development.

The expected process to change some code in production is the following:

  • Update your development environment
  • Test and validate your changes in development
  • Copy the code and the .forestadmin-schema.json from your development environment to your production environment to your production environment

As a consequence if your development environment is working as expected, you can copy the schema from your dev environment and add it to your production.

Perfect, it works now !

Thanks for your precious help !

Have a good day Guillaume

2 Likes