middleware redirect from HTTPS to HTTP
I have set up this middleware to run on all my authenticated routes :
(simplified version) (notice the commented lines setting the protocol)
It all works works well, on page loads.
I am using HTMX and, without some extra work, all my ajax requests are also served through this middleware (by design)
Everything works well, on my computer, working with HTTP.
Once I run it in production (Bun, Hono, proxied through NGINX), my ajax requests stop working, as this middleware redirects to HTTP instead of HTTPS.
so, if i uncomment the lines setting
url.protocol = 'https
, it now works.
This feels like undesired behaviour, is it?
Thank you3 Replies
[UPDATE]:
In the meantime, i realized i don't even have to make the redirects on ajax calls,
as i can get the query string from referer, but my question still stands...
can you not enable force acme or something on your reverse proxy server(for example in nginx)?
i'll look into it
thank you