GiveawayBot icon indicating copy to clipboard operation
GiveawayBot copied to clipboard

Switch to JSONP instead of JSON for Giveaway Summary

Open jagrosh opened this issue 2 years ago • 1 comments

Presently, the giveaway summary file produced at the end of a giveaway is a standard .json file. This is fine, mostly, but since Discord enforces CORS on their cdn, a third-party service is required to load the summary web page (which bypasses the CORS headers and provides the raw json).

Switching GiveawayBot to produce jsonp (json-with-padding) output would allow the summary page to load the summary directly from Discord's cdn, as <script> tags (the underlying tool used for loading jsonp files) ignores CORS.

A few caveats:

  • The system needs to be backwards-compatible. If someone tries to load an older json-style summary, the site will still need to use a third-party url.
  • This will require either a new query parameter in the summary url (such as &v=2) to signify the new system, or a new summary page entirely (/giveaway-summary, for example). I'm leaning towards a query parameter to be more future-proof if more summary loading methods are used in the future.

jagrosh avatar Jan 19 '23 15:01 jagrosh

This needs to be re-evaluated now that Discord is removing persistent download URLs

jagrosh avatar Nov 21 '23 17:11 jagrosh