jona
jona

Reputation: 399

How to integrate Ember.js with Express.js?

I haven't seen an up-to-date question like this one, so here we go.

How would I go about integrating an Ember.js frontend with an Express.js backend? I have an Express app exposing a RESTful API that I'd like to use Ember as a frontend for. Is there an example repo or something to help me get started?

Upvotes: 3

Views: 999

Answers (1)

cswright
cswright

Reputation: 151

Edit: I thought you wanted to serve your app with your Express server. You just want to know how to use a rest api with Ember?

Definitely check out the RESTAdapter or JSONAPIAdapter

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
  namespace: 'api',
  host: 'https://express server here'
});

You should be able to serve the built version of your app with Express the way you normally would

ember build --environment=production

As @GJK pointed out, this isn't necessary for serving your app, but for a production build you would want to do this and serve out of the dist directory

I had an issue serving all of the routes and found this conversation helpful: Rewrite rule

Unfortunately I dont have a repo to point you to but hopefully that helps

Upvotes: 3

Related Questions