question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to serve Ionic app with https?

See original GitHub issue

Running ionic serve allows to run the app on http://0.0.0.0:8100.

Trying to access https://0.0.0.0:8100 results in:

SSL connection error

Is there a way to run the app on https?

The reason I need https is because I use Firebase and it requires requests to be made over https. See: http://stackoverflow.com/q/24431924/247243 http://stackoverflow.com/q/24442013/247243

Any ideas?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

29reactions
nicopacecommented, Jun 6, 2016

Hi guys, This is important because when you are developing a mobile app that uses any html5 feature (geolocation, rotation,…) chrome now requires it to be used from a secured location.

9reactions
c0bracommented, Jun 27, 2014

You could use http-proxy and connect to create a couple https proxy servers, one of which rewrites the livereload port. Just point your browser to https://localhost:8101 instead of 8100.

var fs = require('fs');
var util = require('util');
var httpProxy = require('http-proxy');
var https = require('https');
var connect = require('connect');

// Create a connect app that can transform the response
var app = connect();
app.use(function (req, res, next) {
    if (req.url === '/') {
      util.puts("Transforming response");

      var _write = res.write;

      // Rewrite the livereload port with our secure one
      res.write = function (data) {
        _write.call(res, data.toString().replace('35729', '35700'), 'utf8');
      }
    }

    proxy.web(req, res);
  }
);

// Proxy fpr connect server to use
var proxy = httpProxy.createServer({
  target: {
    host: 'localhost',
    port: 8100
  }
});

// Live reload proxy server
httpProxy.createServer({
  target: {
    host: 'localhost',
    port: 35729
  },
  ws: true,
  ssl: {
    key: fs.readFileSync('server.key', 'utf8'),
    cert: fs.readFileSync('server.crt', 'utf8')
  }
}).listen(35700);

// Create the https server
https.createServer({
  key: fs.readFileSync('server.key', 'utf8'),
  cert: fs.readFileSync('server.crt', 'utf8')
}, app).listen(8101);

util.puts('http proxy server started on port 8101');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic serve with HTTPS secure connection - Stack Overflow
I would like to know how to run ionic application with HTTPS secure connection. There is a HTTPS URL launched inside ionic application...
Read more >
ionic serve
Start a local development server for app dev/testing with ionic serve. ... The dev server can use HTTPS via the --ssl option (experimental)....
Read more >
Configure Angular/Ionic apps with open-ssl certificate to run ...
Configure Angular/Ionic apps with open-ssl certificate to run them securely (over https) locally · Creating the key and certificate · Configuring ...
Read more >
ionic serve --ssl does not take effect for react based projects ...
A workaround is to serve the site with HTTPS=true npm start , which will run react-scripts start with https. See https://create-react-app.dev/ ...
Read more >
Angular & Ionic - How to serve with SSL - YouTube
You do need OpenSSL, and it's expected that you do know that.Simple tutorial for using ionic ssl generate, and how it's setup with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found