Describe the bug
When using the proxy flag set to true, ctx.request.origin ignores it, returning http:// instead of https:// (taken from X-Forwarded-Proto, available in ctx.protocol)
Node.js version: v16.14.0
OS version: Debian 10
Description: With koa's proxy flag to true, ctx.request.origin returns wrong protocol because it doesn't match with the X-Forwarded-Proto header (available in ctx.protocol).
Actual behavior [app.proxy=true]
http://mywebsite.com
Expected behavior [app.proxy=true]
https://mywebsite.com
Code to reproduce
const Koa = require('koa');
const app = new Koa({ proxy: true });
app.use(ctx => {
ctx.body = 'Hello Koa, origin:' + ctx.request.origin + '; protocol=' + ctx.protocol;
});
app.listen(3000);
I didn't submit a pull request since this is a very simple bug and it requires a reverse proxy setup (like nginx) to reproduce
Checklist
Describe the bug
When using the proxy flag set to true, ctx.request.origin ignores it, returning http:// instead of https:// (taken from X-Forwarded-Proto, available in ctx.protocol)
Node.js version: v16.14.0
OS version: Debian 10
Description: With koa's proxy flag to true, ctx.request.origin returns wrong protocol because it doesn't match with the X-Forwarded-Proto header (available in ctx.protocol).
Actual behavior [app.proxy=true]
http://mywebsite.comExpected behavior [app.proxy=true]
https://mywebsite.comCode to reproduce
I didn't submit a pull request since this is a very simple bug and it requires a reverse proxy setup (like nginx) to reproduce
Checklist