1 defmodule Pleroma.Web.Endpoint do
2 use Phoenix.Endpoint, otp_app: :pleroma
4 socket("/socket", Pleroma.Web.UserSocket)
6 socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
8 # Serve at "/" the static files from "priv/static" directory.
10 # You should set gzip to true if you are running phoenix.digest
11 # when deploying your static files in production.
13 plug(Pleroma.Plugs.HTTPSecurityPlug)
15 plug(Pleroma.Plugs.UploadedMedia)
22 ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png schemas)
25 # Code reloading can be explicitly enabled under the
26 # :code_reloader configuration of your endpoint.
28 plug(Phoenix.CodeReloader)
31 plug(TrailingFormatPlug)
37 parsers: [:urlencoded, :multipart, :json],
40 length: Application.get_env(:pleroma, :instance) |> Keyword.get(:upload_limit),
41 body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
44 plug(Plug.MethodOverride)
48 if Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag),
49 do: "__Host-pleroma_key",
52 # The session will be stored in the cookie and signed,
53 # this means its contents can be read but not tampered with.
54 # Set :encryption_salt if you would also like to encrypt it.
59 signing_salt: {Pleroma.Config, :get, [[__MODULE__, :signing_salt], "CqaoopA2"]},
62 Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag),
63 extra: "SameSite=Strict"
66 plug(Pleroma.Web.Router)
69 Dynamically loads configuration from the system environment
72 It receives the endpoint configuration from the config files
73 and must return the updated configuration.
75 def load_from_system_env(config) do
76 port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
77 {:ok, Keyword.put(config, :http, [:inet6, port: port])}