Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you serve ember-cli from https://localhost:4200 in development

For our authentication to work with our ember app we need to serve the app from a secure url. We have a self signed ssl cert.

How do I setup the ember-cli to serve the index.html form a https domain.

Cheers

like image 998
kiwiupover Avatar asked Jan 14 '15 21:01

kiwiupover


People also ask

How do I open Ember command line?

Open http://localhost:4200 in your browser of choice. You should see an Ember welcome page and not much else. If you are having trouble getting this running, other Ember developers would be happy to help! Visit The Ember Community Page to join chat groups or forums.

Which command is used to install the Ember CLI?

Installing Ember is done using NPM. While you're at it we recommend you to also install phantomjs (if you don't have it already). Ember CLI uses phantomjs to run tests from the command line (without the need for a browser to be open).

What is Ember CLI?

Ember CLI, Ember's command line interface, provides a standard project structure, a set of development tools, and an addon system. This allows Ember developers to focus on building apps rather than building the support structures that make them run.

How does Ember serve work?

What it does. ember serve takes all of the app's files and turns them into something that can be rendered in the browser. By default, we can view the app by visiting http://localhost:4200 . It's a good idea to keep the server running as we work so that we know as soon as possible that we've broken something.


2 Answers

Also see https://stackoverflow.com/a/30574934/1392763.

If you will always use SSL you can set "ssl": true in the .ember-cli file for your project which will result in the ember serve command using SSL by default without having to pass the command line flag every time.

By default ember-cli will look in an ssl folder in the root of your project for server.key and server.crt files but you can customize that as well with the --ssl-key and --ssl-cert options to provide an alternate path.

If you don't already have a self signed SSL certificate for development you can follow these instructions to easily generate one: https://devcenter.heroku.com/articles/ssl-certificate-self

Example .ember-cli:

{
  "disableAnalytics": false,
  // Use SSL for development server by default
  "ssl": true,
  "ssl-key": "path/to/server.key",
  "ssl-cert": "path/to/server.crt"
}
like image 121
munsellj Avatar answered Oct 08 '22 21:10

munsellj


EDIT

For googlers, this is no longer true. Use ember-cli --ssl

Thx to xdumaine Jul 12 at 10:08***

emphasized textYou can't directly from ember-cli without putting your hand in the code which I don't recommend :)

If you want to go this way look at: node_modules/ember-cli/lib/tasks/server/express-server.js and may be also into node_modules/ember-cli/lib/tasks/server/livereload-server.js

For those who still want to go through a web server :

However there are other cleaner solutions, for example use nginx as a (reverse) proxy :) or ever serving directly from nginx on the /dist folder :) Reverse basic example with nginx (didn't tried with ssl but should theoretically work :p) :

server {
   listen 443;
   server_name *.example.com;
   ssl on;
   ssl_certificate /path/to/your/certificate.crt;
   ssl_certificate_key /path/to/your/key.key;
   location / {
      proxy_pass http://localhost:4200;
   }
}

I said nginx but actually any webserver can do the trick right :)

NaB DO NOT USE ember serve IN PRODUCTION

like image 38
MrVinz Avatar answered Oct 08 '22 21:10

MrVinz