trestle icon indicating copy to clipboard operation
trestle copied to clipboard

redirect_to not including https when needed

Open NomNomCameron opened this issue 4 years ago • 2 comments

Just ran into an issue with the redirect that happens when saving a resource in the admin dashboard. The response headers location property isn't including https, even when setting Trestle::Engine.routes.default_url_options = { protocol: "https" }

setting config.force_ssl = true doesn't work for me (I think) because the production server is behind a proxy and handles the SSL stuff.

I'm not sure entirely what the proper fix would be here but making Trestle::Engine.routes.default_url_options = { protocol: "https" } would have worked for me.

Wanted to see if anyone else ran into this and/or had any recommendations

NomNomCameron avatar Sep 17 '20 21:09 NomNomCameron

My understanding is that Rails should theoretically be handling this for you, assuming your proxy server is correctly setting the X-Forwarded-Proto header. See https://stackoverflow.com/a/10432596

Also just to clarify, were you able to set Trestle::Engine.routes.default_url_options to solve the issue (perhaps in an initializer)?

spohlenz avatar Sep 21 '20 07:09 spohlenz

I was struggling with an issue like this the last 4 hours. I focused in getting X-Forwarded-Proto = https to Rails and that worked in local development, but not in production (Cloudfront -> Nginx-Ingress -> Nginx-Pod -> Rails).

I resolved it removing these headers (probably added by Nginx-Ingress):

proxy_set_header X-Forwarded-Port "";
proxy_set_header X-Forwarded-Scheme "";
proxy_set_header X-Scheme "";

nedmax avatar May 27 '23 22:05 nedmax