Closed abdonrd closed 8 years ago
Looking at the gulp-gh-pages task it mentions that it will default to the remote URL you're project is setup with (https://github.com/shinnn/gulp-gh-pages#optionsremoteurl). Does that mean if I clone with https I'd get this behavior by default?
@abdonrd If you are deploying on GitHub pages, they are always deployed on HTTPs. What GitHub should also do is upgrade HTTP requests to HTTPs. But I guess they have their reasons.
@robdodson My question is that even if the site can serve/is serving on HTTPs, but user is there on HTTP, will the service worker actually perform?
@VikramTiwari I think (but may be mistaken) that @abdonrd was referring to the gulp task which may attempt to use SSH keys to deploy (but I'll let @abdonrd clarify).
@VikramTiwari no, service workers will only run on https. I don't think GitHub redirects http requests to the https version, but if you're running your own server you can do it. For instance App Engine has an secure: always
key which will automatically redirect http requests to https.
Sorry for the poor explication! :sweat_smile:
I want to force HTTPS because the Service Worker only runs on HTTPS. I was referring precisely to redirect HTTP to HTTPS.
Ah yeah, I guess you could do something like this: https://gist.github.com/konklone/9968713
Maybe we could add that to the GH Pages recipe. Would either of you be interested in trying it out and doing a PR if it works?
@robdodson I am running nginx proxy and redirecting each request to HTTPs using 301 redirect on my servers. But this is an easy fix on the front end. Works! :+1:
@robdodson the solutions of your link works. :)
As we will only add the script to the GH Pages recipe, we can add this:
Normal:
<script>
if (window.location.protocol !== 'https:') {
window.location.protocol = 'https';
}
</script>
Compressed:
<script>'https:'!==window.location.protocol&&(window.location.protocol='https')</script>
Or the deploy-gh-pages
task could add?
yeah I think it'd be better to add it to the recipe. Any interest in putting together a PR for it?
@robdodson sure, one minute!
@robdodson you can check here: https://github.com/PolymerElements/polymer-starter-kit/pull/650. :sunny:
Force HTTPS with Github Pages deployment.