Topher Hunt
Topher Hunt

Reputation: 4803

Elixir Phoenix app returning 431 error when headers are longer than ~4000 chars

My Phoenix app has started giving 431 error responses to some page requests when the user's browser has accumulated too many cookies. (Our site is one subdomain of a very large domain, and many cookies are set globally on the top-level domain.) How can I configure my app to allow longer headers to avoid this error?

Upvotes: 1

Views: 1105

Answers (2)

Thaddeus Jiang
Thaddeus Jiang

Reputation: 172

Try to clean the browser Cookie, like:

enter image description here

Upvotes: 0

Topher Hunt
Topher Hunt

Reputation: 4803

The Phoenix webserver adapter (by default Phoenix.Endpoint.Cowboy2Adapter) allows you to adjust the default max header size etc. For example I ended up using this config:

config :my_app, MyAppWeb.Endpoint,
  http: [
    port: System.get_env("PORT") || "80",
    protocol_options: [max_header_value_length: 8192]
  ],
  ...

For full options & more description, see:

Upvotes: 10

Related Questions