Here are some notes on how to get the ember-cli to connect with Parse (www.parse.com)

** You have to have an account with Parse to do this.

The Problem: How to enable an app in ember-cli to connect with Parse which is an outside server considering the default mode of ember-cli is to prevent connection with servers other than the local server.

The Solution: Change the ember-cli default content security policy to include Parse and add a parse initializer, then use an ember-cli ajax call where you need it.

Solution Steps:

  1. Change the control security policy to include Parse
    In config/environment.js look for or add something like the following:
    contentSecurityPolicy: {
    ‘default-src’: “‘none'”,
    ‘script-src’: “‘self'”,
    ‘font-src’: “‘self'”,
    ‘connect-src’: “‘self’ https://api.parse.com”, //this is the line that includes Parse
    ‘img-src’: “‘self'”,
    ‘style-src’: “‘self'”,
    ‘media-src’: “‘self'”
    }
  2. Create an initializer for Parse
    ember g initializer parse
  3. Add Parse Headers in initializers/parse
    ** Remember that your header info will come from your account not mine!
    I put dashes in the middle so you aren’t tempted to use mine.
    Code in initializers/parse.js looks like:
    Ember.$.ajaxSetup({
    headers: {
    “X-Parse-Application-Id”: “ZYQHOvrj5oPV———-m00ZNLtr5tpd3gzkFi”,
    “X-Parse-REST-API-Key”: “0BRysAUoHF2WsbkYZ———-i1uS31KozIKUz”
    }
  4. Use ajax request where you need it(In controller, model or route)
    Code looks like:
    Ember.$.ajax(“https://api.parse.com/1/classes/Post/” + id, {
    type: ‘DELETE’
    ** Instead of DELETE could be CREATE, READ, UPDATE or DELETE (CRUD)

Leave a Reply

Your email address will not be published. Required fields are marked *