vendredi 24 février 2017

Deploying an Ember.js application with a Node.js backend

I’m new developing with ember and I’m confused with deploying a project. Essentially I have a Linux box running nginx that I want to deploy to. I have a Node.js backend and I’m using ember-cli-delpoy and ember-cli-deploy-build. When I do a ‘ember deploy production’ I can take the ‘deploy-dist’ output directory and point MAMP(apache server) to that directory, and I can access the built ember application. However, the application doesn’t have access to my Node.js backend server. How can I modify my Node.js backend to serve my ember application in a production environment? Below is what my server looks like. I tried to modify the server to point to the ‘deploy-dist’ directory because that made sense to me. But that doesn’t work I get a ‘Cannot GET /‘ message. How can I modify my Node.js application to work in a production environment? Any help is greatly appreciated.

// Working server in ember development mode

/** Dependencies **/
var express    = require('express'),
      path       = require("path"),
      logger     = require('morgan'),
      bodyParser = require('body-parser'),
      connection = require('./config/connection'),
      routes     = require('./config/routes')
      jwt        = require('jsonwebtoken'),
      morgan     = require('morgan'),
      gravatar   = require('gravatar'),
      Router     = express.Router();

module.exports = function(app) {
// Setup
 // Log proxy requests
  app.use(morgan('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  // Requires
  connection.init();
  routes.configure(app ,gravatar ,Router );

}

// modified server

/** Dependencies **/
var express    = require('express'),
      path       = require("path"),
      bodyParser = require('body-parser'),
      connection = require('./config/connection'),
      routes     = require('./config/routes')
      jwt        = require('jsonwebtoken'),
      morgan     = require('morgan'),
      gravatar   = require('gravatar'),
      Router     = express.Router();

/** Setup **/
var app = express();

// Setup
// Log proxy requests
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

app.set('views', __dirname + '/client'); // general config
app.engine('html', require('ejs').__express);
app.set('view engine', 'html');
// Requires
connection.init();
routes.configure(app ,gravatar ,Router );

/** Port **/
app.listen(8000,function(){
  console.log("Listening on Port 8000...");
});




Aucun commentaire:

Enregistrer un commentaire