-
Notifications
You must be signed in to change notification settings - Fork 41
X-HoverXRef-Version
header doesn't get set consistently on readthedocs.io
#165
Comments
X-HoverXRef-Version
doesn't get set consistently on readthedocs.ioX-HoverXRef-Version
header doesn't get set consistently on readthedocs.io
Thanks a lot for such a detailed description! @agjohnson @nienn do you know a good way to solve this problem? is it possible to "append" the function to be called? or at least to check if there are already some defined ones to make the append manually and then re-set it? |
I've never used this method of global configuration, but jQuery doesn't seem to recommend it:
So perhaps configuring the individual |
@davidfischer @agjohnson does it make sense to review the |
We just released |
Yup, looks like it's consistent now. Thanks! |
First of all, thanks for this extension, it's a really neat feature!
There's one issue I've experienced specifically on readthedocs.io, where the custom
X-HoverXRef-Version
header doesn't get set on API requests consistently between page reloads, i.e. it only gets added to requests in some instances.This first appeared since we noticed infrequent/inconsistent CORS issues on a custom domain used with readthedocs.io, which after some debugging turned out to be what I suppose you'd call a race condition between
hoverxref.js
and readthedocs' ownreadthedocs-doc-embed.js
, as both useajaxSetup
to define thebeforeSend
callback:sphinx-hoverxref/hoverxref/_static/js/hoverxref.js_t
Lines 97 to 101 in 3b47d75
https://github.com/readthedocs/readthedocs.org/blob/b958bb8d04c454324d612345890b13af54a19eb6/readthedocs/core/static-src/core/js/doc-embed/footer.js#L31-L37
If the former
ajaxSetup
runs last, theX-HoverXRef-Version
header gets set on every request, which results in CORS issues when not using the proxied API endpoint, asAccess-Control-Allow-Headers
doesn't contain that header.If the latter runs last, hoverxref's
beforeSend
gets overwritten, the header never gets set, and CORS isn't an issue.This primarily happens in Firefox, I haven't been able to reproduce it in Chrome, so perhaps the order in Chrome is deterministic?
After some tinkering and finding #134 I figured out that the trivial solution is of course to just use the proxied API endpoint :) However I still felt like filing this issue since it doesn't change the fact that the header doesn't seem to get set consistently.
(example page with a few xrefs: https://rtd-test.shiftinv.cc/en/test-rtd-cors/whats_new.html#new-features)
The text was updated successfully, but these errors were encountered: