I'm running a shiny app with an original URL "https://shinyapps.io/myapp", and a custom URL "http://mydomain/myapp". I want to redirect all http connections to the original https URL since otherwise users won't be able to use geolocation in the app but I'm a real newbie in JavaScript and I cannot get it done.
I'm trying to test the URL using JavaScript code in the of my app, but URL is redirected in all cases as if my condition was always true :
var protocol = location.protocol;
if (protocol == "http") {
window.location.assign("https://shinyapps.io/myapp")
}
What is wrong with this ? I had answers suggesting correcting protocol = "http" to protocol == "http", which I did, but my test is now always false instead of always true... I guess problem comes from how to write "http" on the right side of the equality, I tried "http:", and "http://" but it didn't change anything. Any clue ? Thanks for your help