I just configured my app with SSL and i see that i have problem with downloading files. On my config i have this:
force_ssl: [rewrite_on: [:x_forwarded_proto], host: "myapp.com"], load_from_system_env: true, url: [host: "myapp.com"], http: [port: 80], force_ssl: [hsts: true], https: [ port: 443, otp_app: :myapp, keyfile: Path.expand("/etc/letsencrypt/live/myapp.com/privkey.pem", __DIR__), certfile: Path.expand("/etc/letsencrypt/live/myapp.com/cert.pem", __DIR__), cacertfile: Path.expand("/etc/letsencrypt/live/myapp.com/fullchain.pem", __DIR__) ]
I have a route that I generate file and i send the file like this:
filename = "my/file/exists/here.pdf" conn |> put_resp_content_type("application/pdf", nil) |> put_resp_header("content-transfer-encoding", "binary") |> put_resp_header( "Content-Disposition", ~s[attachment; filename="file.pdf"] ) |> send_file(200, filename)
The issue is because without SSL everything works fine, but when i added SSL in the route that i generate files, it doesn’t return the file.