Skip to content

loosen up accept headers for AP endpoints #1215

@mayel

Description

@mayel

When fetching an AP actor, curl -v -H "Accept: application/activity+json" and curl -v -H "Accept: */*" both return the JSON, while going to the URL in a browser (firefox) redirects to the profile page, but curl -v -H "Accept: text/html" results in this error:

** (exit) {{{%Phoenix.NotAcceptableError{message: "no supported media type in accept header.\n\nExpected one of [\"json\", \"activity+json\", \"ld+json\"] but got the following formats:\n\n  * \"text/html\" with extensions: [\"html\", \"htm\"]\n\nTo accept custom formats, register them under the :mime library\nin your config/config.exs file:\n\n    config :mime, :types, %{\n      \"application/xml\" => [\"xml\"]\n    }\n\nAnd then run `mix deps.clean --build mime` to force it to be recompiled.\n", accepts: ["json", "activity+json", "ld+json"], plug_status: 406}, [{Phoenix.Controller, :refuse, 3, [file: ~c"lib/phoenix/controller.ex", line: 1606]}, {Bonfire.Web.Router, :activity_json, 2, []}, {Bonfire.Web.Router, :__pipe_through20__, 1, [file: ~c"lib/bonfire/web/router/routes.ex", line: 203]}, {Phoenix.Router, :__call__, 5, [file: ~c"lib/phoenix/router.ex", line: 475]}, {Bonfire.Web.Endpoint, :plug_builder_call, 2, [file: ~c"lib/bonfire/web/endpoint.ex", line: 1]}, {Bonfire.Web.Endpoint, :"call (overridable 3)", 2, [file: ~c"lib/bonfire/web/endpoint.ex", line: 1]}, {Bonfire.Web.Endpoint, :call, 2, [file: ~c"lib/bonfire/web/endpoint.ex", line: 1]}, {Plug.Cowboy.Handler, :init, 2, [file: ~c"lib/plug/cowboy/handler.ex", line: 11]}]}, {Bonfire.Web.Endpoint, :call, [%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}, body_params: %Plug.Conn.Unfetched{aspect: :body_params}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: "bonfire.cafe", method: "GET", owner: #PID<0.25590.0>, params: %Plug.Conn.Unfetched{aspect: :params}, path_info: ["pub", "actors", "mayel"], path_params: %{}, port: 80, private: %{}, query_params: %Plug.Conn.Unfetched{aspect: :query_params}, query_string: "", remote_ip: {0, 0, 0, 0, 0, 65535, 2560, 315}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{"accept", "text/html"}, {"accept-encoding", "gzip"}, {"date", "Wed, 23 Apr 2025 17:48:29 GMT"}, {"host", "bonfire.cafe"}, {"user-agent", "http.rb/5.2.0 (Mastodon/3.4.1 Fedibird/0.1; +https://fedibird.com/

) Bot"}, {"x-forwarded-for", "10.0.0.2"}], request_path: "/pub/actors/mayel", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}], scheme: :http, script_name: [], state: :unset, status: nil}, []]}}, []}

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions