I have downloaded the example and updated it - to include Dashboard as express middleware as below
it loads and looks like /api is the server and /dashboard is the dashboard - when I login to dashboard it shows the APP list BUT says Server not reachable: Invalid server state: initialized
when I look at the chrome network it says {âcodeâ:1,âerrorâ:âInvalid server state: initializedâ}
Help ! >>
import express from âexpressâ;
import { ParseServer } from âparse-serverâ;
import ParseDashboard from âparse-dashboardâ;
import dotenv from âdotenvâ;
import path from âpathâ;
import { fileURLToPath } from âurlâ;
// Load environment variables
dotenv.config();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
// Parse Server configuration
const parseServerConfig = {
databaseURI: process.env.DATABASE_URI || âmongodb://localhost:27017/denaâ,
cloud: process.env.CLOUD_CODE_MAIN || path.join(__dirname, â/cloud/main.jsâ),
appId: process.env.APP_ID || âdenaâ,
masterKey: process.env.MASTER_KEY || âmyMasterKeyâ, // Keep this secret
serverURL: process.env.SERVER_URL || âhttp://127.0.0.1:1337/apiâ, // URL of your Parse Server
publicServerURL: process.env.PUBLIC_SERVER_URL || âhttp://127.0.0.1:1337â,
appName: process.env.APP_NAME || âdenaâ,
logLevel: process.env.LOG_LEVEL || âinfoâ,
// Removed invalid options: serverInfo and allowOrigins
emailAdapter: {
module: âsimple-parse-smtp-adapterâ,
options: {
fromAddress: process.env.EMAIL_FROM_ADDRESS,
user: process.env.EMAIL_USERNAME,
password: process.env.EMAIL_PASSWORD,
host: process.env.EMAIL_SMTP,
isSSL: process.env.EMAIL_SSL === âtrueâ,
port: parseInt(process.env.EMAIL_PORT) || 465,
name: process.env.EMAIL_NAME,
},
},
};
console.log (parseServerConfig);
// Create a new Parse Server instance
const parseServer = new ParseServer(parseServerConfig);
// Serve the Parse API on the /api URL prefix
app.use(process.env.PARSE_SERVER_MOUNT || â/apiâ, parseServer.app); // Correct way to pass Parse Server as middleware
// Parse Dashboard configuration
const dashboardConfig = {
apps: [
{
serverURL: process.env.SERVER_URL || âhttp://127.0.0.1:1337/apiâ,
appId: process.env.APP_ID || âdenaâ,
masterKey: process.env.MASTER_KEY || âmyMasterKeyâ,
appName: process.env.APP_NAME || âdenaâ,
readOnlyMasterKey: process.env.READ_ONLY_MASTER_KEY
},
],
users: [
{
user: process.env.PARSE_DASHBOARD_USER || âadminâ,
pass: process.env.PARSE_DASHBOARD_PASS || âpasswordâ,
},
{
user: process.env.PARSE_DASHBOARD_USER_READ_ONLY || âreadonlyâ,
pass: process.env.PARSE_DASHBOARD_PASS_READ_ONLY || âreadonlypassâ,
readOnly: true,
},
],
useEncryptedPasswords: false, // Set to true if passwords are encrypted
allowInsecureHTTP: true, // Set to true only for development; for production, use HTTPS
trustProxy: 1
};
console.log (dashboardConfig);
// Create a new Parse Dashboard instance
const dashboard = new ParseDashboard(dashboardConfig);
// Serve the dashboard at /dashboard
app.use(â/dashboardâ, dashboard);
// Start the server
const port = process.env.PORT || 1337;
const httpServer = app.listen(port, () => {
console.log(Server running on port ${port}
);
console.log(Parse Server running on ${process.env.SERVER_URL}
);
console.log(Parse Dashboard running on http://localhost:${port}/dashboard
);
});
// Enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);
export default app;