Created
August 28, 2017 08:24
-
-
Save shanelau/2e3c46a95af4a51e7600d0b432eeaf0b to your computer and use it in GitHub Desktop.
http redirect to https
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (app.config.env === 'prod') { | |
// SLB 的 https 会添加 请求头部 x-forwarded-proto | |
const isHttps = this.ctx.request.headers['x-forwarded-proto'] && (this.ctx.request.headers['x-forwarded-proto'] === 'https'); | |
if (!isHttps) { | |
return this.ctx.redirect(this.ctx.href.replace('http://', 'https://')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment