elk-zone / elk

A nimble Mastodon web client
https://elk.zone
MIT License
5.34k stars 552 forks source link

Improve content negotiation handling for forwarding AS2 requests #2463

Open snarfed opened 10 months ago

snarfed commented 10 months ago

Hi all! First off, thank you for building and maintaining Elk. It's great!

A few of us noticed recently in https://github.com/elk-zone/elk/discussions/2457 that Elk's Accept header parsing for content negotiation is pretty brittle and limited. It looks like it only forwards requests to the underlying Mastodon instance if the Accept header is exactly application/ld+json; profile="https://www.w3.org/ns/activitystreams". If it's at all different, eg even just removing the space to get application/ld+json;profile="https://www.w3.org/ns/activitystreams", Elk serves HTML instead of forwarding.

(My service uses a more involved Accept: application/activity+json; q=0.9, application/ld+json; profile="https://www.w3.org/ns/activitystreams"; q=0.8, text/html; charset=utf-8; q=0.7, which Elk also doesn't handle.)

Thanks in advance for looking at this!

(Btw, on a related note, lower priority, any chance you could configure https://elk.zone/ to forward AS2 conneg requests too? Right now it doesn't, even with the exact Accept header above.)

stackblitz[bot] commented 10 months ago

Solve in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.