Polymer / prpl-server

⚠️Maintenance mode⚠️ An HTTP server for Node designed to serve PRPL apps in production.
Other
425 stars 29 forks source link

HTTPS redirect when using prpl-server-node as a library #79

Closed JaimeFerBec closed 6 years ago

JaimeFerBec commented 6 years ago

The documentation mentions the option of HTTPS redirect by setting the --https-redirect flag when using prpl-server-node as a binary, but I don't see how I could set that same option to true when using prpl-server-node as a library. I have checked src/prpl.ts but I don't see any point where an https redirect is done.

benjaminrancourt commented 6 years ago

The only mention of https-redirect is in src/cli.ts. One way to achieve what you want could be to implement the same middleware used in src/cli.ts in your application.

aomarks commented 6 years ago

Yes, I would suggest just copying the snippet @ranb2002 linked above, or you could try something like https://github.com/buchanan-edwards/express-https-redirect (I have not used it, but looks like it does the right thing). The reason it's not included in the prpl express middleware is to keep it scoped to differential serving, since there are existing solutions to things like HTTPS redirection that you can easily add in.

JaimeFerBec commented 6 years ago

I ended up doing exactly what @ranb2002 pointed out. I will take a look at express-http-redirect too. I just wanted to know if you missed that feature in the prpl express middleware, but I now see that you intentionally omitted it, and your explanation @aomarks is quite reasonable. Thanks for the help and info!