Serve locally using Https


#1

Is there a way to configure ionic to serve locally using https?
My remote host is SSL and all secure cookies are lost when they come back to the non-SSL browser.

What is the easiest way to solve my problem?

Thanks in advance.


#2

Can you give an example of what you are trying to do. Why would you be serving https from ionic?


#3

after I logged in to SSL server it sends back secure cookie with sessionId.
I need that cookie to make other requests BUT non-SSL browser mode doesn’t allow to share secure cookies.
As a result I can not sent sessionId and have 401 ‘Unauthorized’ response from a server.


#4

after I logged in to SSL server it sends back secure cookie with sessionId.

So is your ionic app connecting to a server using SSL or is it Serving SSL?


#5
  1. I’m sending authentication request from my app to SSL server using ionic proxy.
  2. Server response contain sessionId in secure cookie.
  3. I’m sending another request that suppose to have this sessionId in requestHeader cookie.

In reality the last request doesn’t have sessionId in requestHeader coockie and thats why I get 401 ‘Unauthorized’.
When I look at responseHeader cookie of the first request I see the following:
set-cookie:PHPSESSID=5583u6dcq803qlm5mnnc79vua4i0hs10htoj1mavskhv0bdg8m31; path=/; secure; HttpOnly

My idea is to make it somehow run locally in secure mode so that this secure cookie would be passed through.


#6

Hey @qvatra !, Im currently facing the same issue. It would be nice to have something like “ionic serve https” to bootstrap localhost in a secure environment, what is required by a lot of services like google maps, aws cognito, auth0, firebase, etc. Not sure where the confusion is @rwildcard , it is a very common use case. If ionic were using something like browsersync, we could just add our self-signed certs in a config file i.e.:

,“https”: {
“key”: “/Users/rcfrias/.localhost-ssl/key.pem”,
“cert”: “/Users/rcfrias/.localhost-ssl/cert.pem”
}

@rwildcard what do you mean with -> “Why would you be serving https from ionic” afaik ionic uses the “serve” command to create a standalone web server to host the ionic app, not to serve anything else. So by “serve” it can only be the app itself. Default -> http://localhost:8100/ / desired -> https://localhost:8100/


#7

I have the same problem, how can we use https://localhost:8100 ?
In my case I can’t use cordova-plugin-geolocation with --livereload because it’s forbidden to get geolocation from unsecured origins:


#8

@fdambrosio Did you ever find a solution to this problem? I’m attempting to configure my application to serve through https to fix this exact same problem as well. Pretty disappointed by how complicated most “solutions” I’ve come across have been.


#9

@zachonahill no I’m sorry, I’ve not found a solution yet


#10

Hey, I am also facing the same issue. Did you able to resolve this issue.


#11

Hi @rcfrias,

In my app I use an iframe and I call a website using https. It works just fine, I rarely test my apps with the browser due to the features I need are usually only found on the device. Do you find that it works on the device when you test it or is it a problem that is in both the browser and on your device?

I may run into this with my next app as I will be dropping the iframe and replace it with api’s. @fdambrosio are you making an app or is this to be run on the browser? I just want to make sure I understand this.