-
Notifications
You must be signed in to change notification settings - Fork 279
adds ProxyFix for Cloud9 #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@kzidane mind taking a look? |
src/cs50/flask.py
Outdated
@@ -22,7 +22,7 @@ | |||
|
|||
# Add support for Cloud9 proxy so that flask.redirect doesn't redirect from HTTPS to HTTP | |||
# http://stackoverflow.com/a/23504684/5156190 | |||
if getenv("C9_HOSTNAME") and not getenv("IDE_OFFLINE"): | |||
if getenv("C9_PROJECT") == "ide50" and not getenv("IDE_OFFLINE"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come better, @kzidane?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C9_HOSTNAME
is set offline as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's why we're checking and not getenv("IDE_OFFLINE")
too, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in that case we could just check for IDE_OFFLINE
really since it's not set online. C9_PROJECT
is set to a different value online ("ide50"
) vs offline ("ide50-offline"
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be different logic. We need the ProxyFix iff using CS50 IDE Online.
This reverts commit 7383f11.
This monkey-patches
flask.Flask
so thatapp
is wrapped with http://werkzeug.pocoo.org/docs/0.14/contrib/fixers/#werkzeug.contrib.fixers.ProxyFix on Cloud9 (online), which ensuresflask.redirect
won't redirect from HTTPS to HTTP. Sample app intests/redirect/
.Seems best to monkey-patch rather than add, e.g., http://stackoverflow.com/a/23504684/5156190 to students' own
application.py
files, lest they reuse that file on a non-proxied setup, which isn't recommended: