You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mtrezza
changed the title
Does someone use Parse in combination with NextJs (React)?
Error: "Unable to connect to 'http://localhost:1337/parse'" with NextJs (React)
Feb 3, 2021
I'm closing this as it lacks essential information required to investigate the issue. Please follow up on any questions asked and further steps suggested in the thread and we can re-open this issue.
I'm using a custome NextJs server with express and Parse Server.
here is my custom server:
`
/** ----------------------------------------------------- /
/* ------------------- Custom Server ------------------- /
/* ----------------------------------------------------- */
const express = require('express');
const dotenv = require('dotenv');
const next = require('next');
const path = require('path');
const { getParseServer, getParseDashboard } = require('./parse');
const dev = process.env.NODE_ENV !== 'production';
const port = 3000;
// Create the Express-Next App
const app = next({ dev });
const handle = app.getRequestHandler();
// ------------------------------------------------------------------------- //
// ------------------------ envvars initialisation ------------------------- //
// ------------------------------------------------------------------------- //
let envFileName;
if (dev) {
envFileName = '.env.local';
} else {
envFileName = '.env.prod';
}
dotenv.config({ path: path.join(__dirname, envFileName) });
app
.prepare()
.then(() => {
const server = express();
});
`
and here is the parse file initialization / configuration:
`
const { ParseServer } = require('parse-server');
const ParseDashboard = require('parse-dashboard');
const path = require('path');
// must be secrets
const APP_ID = 'increzia';
const MASTER_KEY = 'increziaApp';
const APP_NAME = 'Increzia';
const DASHBOARD_USER = 'michael';
const DASHBOARD_PASSWORD = 'michael';
const getServerUrl = () =>
${process.env.HOST}:1337/parse
;const getParseServer = () => {
const DB_URL = process.env.DBURL;
const parseServerAPI = new ParseServer({
databaseURI: DB_URL,
cloud: path.resolve(__dirname, 'server/cloud/main.ts'),
appId: APP_ID,
masterKey: MASTER_KEY,
serverURL: getServerUrl(),
appName: APP_NAME,
});
return parseServerAPI;
};
const getParseDashboard = () => {
const dashboard = new ParseDashboard({
apps: [
{
serverURL: getServerUrl(),
appId: APP_ID,
masterKey: MASTER_KEY,
appName: APP_NAME,
},
],
users: [
{
user: DASHBOARD_USER,
pass: DASHBOARD_PASSWORD,
apps: [{ appId: APP_ID }],
},
],
});
return dashboard;
};
exports.getParseServer = getParseServer;
exports.getParseDashboard = getParseDashboard;
`
and my package.json scripts:
"scripts": { "dev": "next dev", "server": "node server.js", "reload": "nodemon server.js", "prod": "cross-env NODE_ENV=production node server.js", "build": "next build", "build-static": "next build & next export", "start": "next start", "lint": "eslint --fix . --ext .js,.jsx,.ts,.tsx", "storybook": "start-storybook -s ./public -p 6006", "build-storybook": "build-storybook --no-dll -s ./public" },
but I got this error:
The text was updated successfully, but these errors were encountered: