Hello everyone,
We are not able to connect to our development env after upgrading the forest admin. We have followed the upgrade guide provided in the documentation (regarding our Happyporteur app).
Same API is working from the our deliveryman option.
Thanks,
Kind regards,
Alexis Montcel
App.js
const express = require(“express”);
const requireAll = require(“require-all”);
const path = require(“path”);
const cookieParser = require(“cookie-parser”);
const bodyParser = require(“body-parser”);
const cors = require(“cors”);
const jwt = require(“express-jwt”);
const morgan = require(“morgan”);
const { errorHandler, logger } = require(“forest-express”);
const {
ensureAuthenticated,
PUBLIC_ROUTES,
} = require(“forest-express-sequelize”);
const app = express();
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,
// 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(morgan(“tiny”));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, “public”)));
app.use(
jwt({
secret: process.env.FOREST_AUTH_SECRET,
credentialsRequired: false,
})
);
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({ logger }));
module.exports = app;