fix: static files served with different vary headers #26532
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
I believe that because
vary: accept-encoding
access-control-allow-origin: https://posthog.com
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 theCorsPostCsrfMiddleware
middleware that I think would add the domain specificaccess-control-allow-origin
header in django shouldn't run on these static file requestsI 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 stackI 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