Trying to migrate to a new server with the current database and the same codebase

[Picture deleted][Picture deleted]

I need the response, this is still what is sent :wink:

I don’t have a call from this url in the network tab

I can send you the .har file with all the network traffic but it is over 15mb (over the 8mb limit here) and does not contain https://api.development.forestadmin.com/api/projects/:projectId/environments

I deleted the development branch that directed to localhost, even though I was trying to connect to the production branch, and now I am getting a different error when trying to connect:

Hmm, it’s a CORS issue. Could you share you CORS configuration ?

app.use(cors({
  credentials: true,
  origin: [
    /green-swan\.netlify\.app$/,
    /green-swan-dev\.netlify\.app$/,
    /greenswanlab\.com$/,
    /\.greenswanlab\.com$/,
    /\.forestadmin\.com$/,
    /localhost:\d{4}$/
  ]
}));

The server code has not changed when migrating to the new server and this code works with the GSL_Admin project in the production environment

import express from "@feathersjs/express";
import dotenv from "dotenv";
import jwt from "express-jwt";
import Liana, { ensureAuthenticated, PUBLIC_ROUTES } from "forest-express-mongoose";
import Mongoose from "mongoose";
import path from "path";
import { Application } from "./declarations";
import logger from "./logger";
import projectAssessmentsRoutes from "./routes/projectassessments";
import projectRoutes from "./routes/projects";
import userRoutes from "./routes/users";

dotenv.config();

export default async function forestAdmin(app: Application) {
  const connection = app.get("mongooseClient");
  const forestConfig = app.get("forestAdmin");

  console.log(`forestConfig.envSecret: ${forestConfig.envSecret}`)
  console.log(`forestConfig.authSecret: ${forestConfig.authSecret}`)

  const liana = await Liana.init({
    configDir: path.join(__dirname, '/forest'),
    envSecret: forestConfig.envSecret,
    authSecret: forestConfig.authSecret,
    schemaDir: process.env.FOREST_SCHEMA_DIR,
    objectMapping: Mongoose,
    connections: {
        default: connection
    }
  });

  app.use(liana);

  app.use(
    jwt({
      secret: forestConfig.authSecret,
      credentialsRequired: false,
      algorithms: ["HS256"],
    })
  );

  app.use(['/forest', '/forest/*'], (request: any, response: any, next: any) => {
    logger.info("forest route");
    if (PUBLIC_ROUTES.includes(request.url)) {
      logger.info("public forest route");
      return next();
    }
    logger.info("checking authentication");
    return ensureAuthenticated(request, response, next);
  });

  app.configure(projectAssessmentsRoutes);
  app.configure(projectRoutes);
  app.configure(userRoutes);
  
  app.use(express.notFound());
  app.use(express.errorHandler({ logger } as any));
}

This is the code we use on the server to communicate with forest. It works when running on the localhost during the initial setup. Is there something here that can cause this issue in the production environment?

Could you try something like:

app.use(cors({
  credentials: true,
  origin: [
    /green-swan\.netlify\.app$/,
    /green-swan-dev\.netlify\.app$/,
    /greenswanlab\.com$/,
    /\.greenswanlab\.com$/,
    /\.forestadmin\.com$/,
    /localhost:\d{4}$/,
    null
  ],
  credentials: true,
  allowedHeaders: ['Authorization', 'X-Requested-With', 'Content-Type', 'Forest-Context-Url'],
}));

let me know if it works

I added your code, besides the null that caused the ts error about string not being able to be null, but I still get the same error

Which cors package are you using ?

In the absence of response I will close the ticket