Expected behavior
Forest Admin UI can access local node server backend.
Actual behavior
CORS in the browser (Google Chrome) fails because the express server returns a 404 Not Found
for the OPTIONS /forest/sessions-google
request made by the Forest Admin UI. All my own routes work fine. It may be worth noting that I am using node clustering but that it is set up in such a way that each client will connect to the same process in order to get socket-io auth to work properly.
Failure Logs
Express server logging:
Child(46425): req.headers { host: 'localhost:3000',
connection: 'keep-alive',
accept: '*/*',
'access-control-request-method': 'POST',
'access-control-request-headers': 'content-type',
origin: 'http://app.forestadmin.com',
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko). Chrome/87.0.4280.67 Safari/537.36',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'sec-fetch-dest': 'empty',
referer: 'http://app.forestadmin.com/',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8' }.
Child(46425): [::1] OPTIONS /forest/sessions-google 404 9B - 0.354 ms
Context
app.use(
'/forest',
cors({
origin: [/\.forestadmin\.com$/],
allowedHeaders: ['Authorization', 'X-Requested-With', 'Content-Type'],
credentials: true,
}),
forestRouter
);
const forestConfig = {
modelsDir: __dirname + '/models',
envSecret: process.env.FOREST_ENV_SECRET,
authSecret: process.env.FOREST_AUTH_SECRET,
mongoose: mongoose,
};
app.use(require('forest-express-mongoose').init(forestConfig));
- Package Version:
“forest-express-mongoose”: “^3.2.4” - Express Version:
“express”: “~4.16.0” - Mongoose Version:
“mongoose”: “^5.7.10” - Database Dialect:
MongoDB - Database Version:
mongod --version
db version v4.2.8