Serve locally using Https

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.

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

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.

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?

  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.

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/

1 Like

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:

1 Like

@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.

@zachonahill no Iā€™m sorry, Iā€™ve not found a solution yet

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

1 Like

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.