Closed sudhanshugaur4 closed 6 years ago
Hi, this plugin also didn't work for me on Google App Engine Flex. I used express-sslify instead. With this extension you can set trustProtoHeader parameter as true, which looks for x-forwarded-proto header sent from App Engine.
Example code with added support for production env and health check, specific for App Engine: https://gist.github.com/martyciz/103477b4db322b6462931b33f7baf953#file-server-js
Hii @martyciz actually both plugins are currently working for me. The mistake I was doing was I was putting them on the middleware after the setting the /public
directory, but the right way was to put it before setting /public
directory.
Right Code
app.use(yes({
maxAge: 86400, // defaults `86400`
includeSubdomains: true, // defaults `true`
preload: true // defaults `true`
}));
app.use(express.static(__dirname + '/public'));
Wrong Code
app.use(express.static(__dirname + '/public'));
app.use(yes({
maxAge: 86400, // defaults `86400`
includeSubdomains: true, // defaults `true`
preload: true // defaults `true`
}));
Because of which Https was not enforcing but now everything is working as expected.
app.use(yes({ maxAge: 86400, // defaults
86400
includeSubdomains: true, // defaultstrue
preload: true // defaultstrue
}));
Previously this code was working fine and all my requests whether Https OR Http all were getting routed to Https. But now I don't know why requests coming to Http is not getting routed to Https.