To secure the transmission of sensitive data between client and server by using encryption.
# In config/prod.exs
config :my_app, MyAppWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 80],
url: [scheme: "http", host: "example.com", port: 80]
In this insecure code, the application is configured to communicate over HTTP (port 80) which is a non-encrypted, insecure communication protocol. This can expose sensitive data like user credentials to eavesdroppers.
# In config/prod.exs
config :my_app, MyAppWeb.Endpoint,
https: [ip: {127, 0, 0, 1}, port: 443, keyfile: "priv/ssl/selfsigned.key", certfile: "priv/ssl/selfsigned.crt"],
url: [scheme: "https", host: "example.com", port: 443]
In this secure code, the application is now configured to communicate over HTTPS (port 443) with the SSL certificate. This secures the transmission of sensitive data with encryption.