PostHog / posthog

🦔 PostHog provides open-source web & product analytics, session recording, feature flagging and A/B testing that you can self-host. Get started - free.
https://posthog.com
Other
22.33k stars 1.35k forks source link

fix: static files served with different vary headers #26532

Closed pauldambra closed 2 days ago

pauldambra commented 2 days ago

when using internal-t posthog route (which i think is just PostHog and managed reverse proxy)

going backwards and forwards between us.posthog.com and posthog.com I get a CORS error

Screenshot 2024-11-28 at 23 10 20 Screenshot 2024-11-28 at 22 31 08

I believe that because

the default headers from whitenoise are https://github.com/evansd/whitenoise/blob/b3d250fd17da0e280d58b6dc4935c4573ebe8b55/src/whitenoise/responders.py#L170 vary: accept-encoding so it's probably whitenoise adding the vary headers for us (i guess it could be contour or envoy but that feels like it's whitenoise)

NB the real fix here IMO is to send access-control-allow-origin: * but the CorsPostCsrfMiddleware middleware that I think would add the domain specific access-control-allow-origin header in django shouldn't run on these static file requests

I don't think it is since it would add the vary: origin header, so I think the access-control-allow-origin is being added somewhere else in the stack

I don't know where in the stack, so for the time being we can try and add the vary by origin header. this means folk will download the assets more often than they strictly need to but that's better than current

I haven't tested this since whitenoise doesn't serve static assets in DEBUG