1 defmodule Pleroma.Web.Endpoint do
2 use Phoenix.Endpoint, otp_app: :pleroma
4 if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
5 socket("/socket", Pleroma.Web.UserSocket)
8 socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
10 # Serve at "/" the static files from "priv/static" directory.
12 # You should set gzip to true if you are running phoenix.digest
13 # when deploying your static files in production.
16 plug(Plug.Static, at: "/media", from: Pleroma.Uploaders.Local.upload_path(), gzip: false)
23 ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png schemas)
26 # Code reloading can be explicitly enabled under the
27 # :code_reloader configuration of your endpoint.
29 plug(Phoenix.CodeReloader)
32 plug(TrailingFormatPlug)
38 parsers: [:urlencoded, :multipart, :json],
41 length: Application.get_env(:pleroma, :instance) |> Keyword.get(:upload_limit),
42 body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
45 plug(Plug.MethodOverride)
48 # The session will be stored in the cookie and signed,
49 # this means its contents can be read but not tampered with.
50 # Set :encryption_salt if you would also like to encrypt it.
55 signing_salt: "CqaoopA2",
58 Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag),
59 extra: "SameSite=Strict"
62 plug(Pleroma.Web.Router)
65 Dynamically loads configuration from the system environment
68 It receives the endpoint configuration from the config files
69 and must return the updated configuration.
71 def load_from_system_env(config) do
72 port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
73 {:ok, Keyword.put(config, :http, [:inet6, port: port])}