How do I configured CORS middleware when using the forestadmin agent?
I need to return the access-control-allow-origin header.
Here’s is my index.js, what should I add?
const agent = createAgent({
// Security tokens
authSecret: process.env.FOREST_AUTH_SECRET,
envSecret: process.env.FOREST_ENV_SECRET,
// Make sure to set NODE_ENV to 'production' when you deploy your project
isProduction: process.env.NODE_ENV === 'production',
// Autocompletion of collection names and fields
typingsPath: './typings.ts',
typingsMaxDepth: 5,
});
// Connect your datasources
// All options are documented at https://docs.forestadmin.com/developer-guide-agents-nodejs/data-sources/connection
agent.addDataSource(
createSqlDataSource({
uri: process.env.DATABASE_URL,
schema: process.env.DATABASE_SCHEMA,
sslMode: process.env.DATABASE_SSL_MODE,
}),
);
// Expose an HTTP endpoint.
agent.mountOnStandaloneServer(Number(process.env.APPLICATION_PORT));
// Start the agent.
agent.start().catch(error => {
console.error('\x1b[31merror:\x1b[0m Forest Admin agent failed to start\n');
console.error('');
console.error(error.stack);
process.exit(1);
});