I am using angular 8 with ionic (mobile).
I have problem when running the application, opened in chrome browser, in production mode, while there is no problem when opening in development mode.
I realized that there are some different behaviors when running the code just by ionic server
.
or after compiling with to production:
ionic build --prod --release
and do:
cd www
and run:
http-server
Only for http-server
there is a problem when refreshing the page:
This localhost page can’t be foundNo webpage was found for the web address: https://localhost:8080/mypage
HTTP ERROR 404
… while running via ionic serve
there is no problem.
Also, when I open chrome dev-tools
(press F12
) and go to application tab.
I see that IndexDB is cleared when I am doing page refresh (that only happens for http-server).
My assumption this related to some security issues for using storage data and maybe related to few more issues.
The default for http-server, when I running it is http (not https). Should I run it as https?
I tried to configured *.crt file (by openssl):
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem
and import to certificate local manager: certlm.msc
and run
http-server -S -C cert.pem -K key.pem
(I copied the certificate files to the www folder) – same problem.
Nonetheless, I don’t know whether run for https is must for solving the issue, or I can keep running in http.
Why is disparities between running ionic serve
and http-server
and how can I solve this issue?
5