0

I have installed bitnami parse server from the AWS market place to provide the backend for an iOS app. In the iOS app the API is configured under http://myURL.com/parse and when I go to what I thought would be the homepage, http://myURL.com, it instead redirects me to the parse dashboard located at http://myURL.com/apps. I would like to have http://myURL.com serve a homepage for my app instead of redirecting to the parse dashboard so that a web application can be constructed that shares the same data the app uses. This is my first project using node.js so I am hoping someone could point me in the right direction on a couple of topics. My previous web application work was always on a LAMP stack so I am curious:

  • Am I correct to assume that the parse backend that iOS uses can also be the backend for a web application accessed through a browser?
  • When I analyze the code in server.js at /home/bitnami/apps/parse/htdocs I don't see a function that is redirecting to myURL.com/apps, is there a different area I should be focussed on to understand how myURL.com gets redirected to the apps folder?
  • I noticed that a folder exists at /home/binami/apps/rockmongo with installation instructions of php scripts, can my AWS instance run php AND the node.js or will installing a LAMP stack interfere with the node.js stack?
  • I am sure there is some great documentation and/or tutorials on this, can you help me get started by providing the correct way to phrase google searches or even better any links to tutorials themselves?

For context my iOS lets users log on and lets them upload images to parse server classes, I simply want to let the users log on and upload an image from a web browser using the same parse server which has the user/file classes.

For Reference below is the server.js which appears to somehow be directing requests from myURL.com to myURL.com/apps:

require('dotenv').config();
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
    databaseURI: "mongodb://root:9dh********@127.0.0.1:27017/bitnami_parse",
    cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
    appId: "19defd7********",
    masterKey: "cd8********",
    fileKey: "3bce6********",
    serverURL: "http://54.**.**.**:80/parse",
    filesAdapter: {
        "module": "@parse/s3-files-adapter",
        "options": {
            "bucket": process.env.S3_BUCKET,
        }
    },
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var port = 1337;
app.listen(port, function() {
    console.log('parse-server running on port ' + port);
});

//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
    apps: [
        {
            appName: "My Bitnami Parse API",
            appId: "19defd7********",
            masterKey: "cd8d*******",
            fileKey: "3bce6********",
            production: true,
            serverURL: "http://54.**.**.**:80/parse"
        }
    ],
    users: [
        {
            user: process.env.ADMIN_USER,
            pass: process.env.ADMIN_PASSWORD
        }
    ], useEncryptedPasswords: true
});

var allowInsecureHTTP = true;

// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);

var portdash = 4040;
app.listen(portdash, function() {
    console.log('parse-dashboard running on port ' + portdash);
});

1 Answer 1

2

Mount point for Parse Dashboard is definded in this line:

app.use('/', dashboard);

When you want to use a separate mount point for dashboard you can do this:

app.use('/dashboard', dashboard);

After changing if you hit http://myURL.com/dashboard it will load the dashboard in /dashboard/apps. '/apps' endpoint is handled by parse dashboard itself.

Now if you want to load your website in root route (/) or the http://myURL.com, you need to create another route (assuming you want to serve a static site for now)

app.use('/public', express.static(path.join(__dirname, '/public'), {
   etag: true
}));

app.get('/', function (req, res) {
   res.sendFile(path.join(__dirname, '/public/index.html'));
});

To serve a static site you need to create a folder from where you will server the static site. In this case, I created a folder named as public and place all of my html,css,js there. Now I need to specify the static folder in express. That's what I did in the first line. After that, I simply serve the index.html by creating a 'GET' route.

You can do a lot of other things too like creating APIs or serve a dynamic website as well as using parse server. But to do that you must understand express framework with nodejs first.

Update: Parse API and Dashboard are two separate things. You can run only parse-server without dashboard and vice-versa. In your code, you mount the parse-server in /parse endpoint. Look at this line

app.use('/parse', api);

So now the parse-server is available in /parse endpoint. You can change it to anything. Make separate endpoints for both parse-server and dashboard.

Sign up to request clarification or add additional context in comments.

2 Comments

Changing app.use('/',dashboard); is the solution and I just wanted to note that the new name (e.g. app.use('/dashboard', dashboard);) can't begin with the string "parse". I tried to do that and had to google around to figure out why it wasn't working so thought it would be a good comment to add.
@DanielPatriarca See the updated portion of the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.