learningequality / ka-lite

KA Lite: lightweight web server for serving core Khan Academy content (videos and exercises) without needing internet connectivity
https://learningequality.org/ka-lite/
Other
457 stars 304 forks source link

Add additional logging during AJAX request failures + CSP middleware for debugging #5403

Closed benjaoming closed 7 years ago

benjaoming commented 7 years ago

Summary

Since the actual issue was due to upstream HTTP headers and OPTIONS returning 405, there was nothing to fix.

Instead, I leave us with some:

1) Removes some homebrewed JsonAsHTML debug middleware that was really breaking stuff in debug mode. 1) Additional JS console output in case of failure 1) Fixing broken debug-toolbar due to fetching online resources 1) A CSP middleware that's only enabled with DEBUG=True and blocks online sources so we won't make mistakes in the future 1) Disables tota11y by default, but enables it with USE_TOTA11Y=True in settings @radinamatic

TODO

If not all TODOs are marked, this PR is considered WIP (work in progress)

Issues addressed

5348

codecov-io commented 7 years ago

Codecov Report

Merging #5403 into 0.17.x will decrease coverage by -0.06%.

@@            Coverage Diff             @@
##           0.17.x    #5403      +/-   ##
==========================================
- Coverage   51.82%   51.76%   -0.06%     
==========================================
  Files         143      143              
  Lines        7491     7499       +8     
==========================================
  Hits         3882     3882              
- Misses       3609     3617       +8
Impacted Files Coverage Δ
kalite/project/settings/dev.py 0% <ø> (ø) :white_check_mark:
...ite/distributed/features/steps/superuser_create.py 95.52% <100%> (+1.15%) :white_check_mark:
kalite/distributed/middleware.py 55.55% <46.66%> (-9.16%) :x:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5c96dbc...eaec70f. Read the comment docs.

benjaoming commented 7 years ago
$.ajax({url: "http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/all_metadata.json"}).success(function(resp) {console.log("succ")}).fail(function(resp) {console.log("fail: " + resp.state())})

fail: rejected

Interesting.. it fails with "rejected". I have cleared all my browser cache in case it had to do with cached OPTIONS 405s.

However, this works:

$.ajax({url: "http://mysafeinfo.com/api/data?list=englishmonarchs&format=json"}).success(function(resp) {console.log("success")}).fail(function(resp) {console.log("fail: " + resp.state())})

success

So I'm assuming this has to do with a problem with FF or our setup. I'm still not convinced about our Nginx settings :)

benjaoming commented 7 years ago

Well well well, trying a clean FF profile makes it work.

I can't make it work by clearing my cache with CTRL+SHIFT+DEL, just a heads up to anyone encountering the issue.