Skip to content

Commit

Permalink
THIS_URL setting improve, use in cors origin
Browse files Browse the repository at this point in the history
  • Loading branch information
n8kim1 committed Dec 28, 2020
1 parent 1a043c0 commit bccf21e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ def signed_upload_url(file_path, bucket):
# https://stackoverflow.com/questions/25688608/xmlhttprequest-cors-to-google-cloud-storage-only-working-in-preflight-request
# https://stackoverflow.com/questions/46971451/cors-request-made-despite-error-in-console
# https://googleapis.dev/python/storage/latest/blobs.html
# TODO this should be dynamic.
# in fact, "this website" should become a config setting;
# also, in the setup readme, should be a note about changing this setting
return blob.create_resumable_upload_session(origin='http://localhost:3000')
return blob.create_resumable_upload_session(origin=settings.THIS_URL)

@staticmethod
def signed_download_url(file_path, bucket):
Expand Down
1 change: 1 addition & 0 deletions backend/dev_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
THIS_URL = 'http://localhost:3000'

# Application definition
INSTALLED_APPS += ['debug_toolbar']
Expand Down
4 changes: 4 additions & 0 deletions backend/docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Deployment is done through the Google Cloud Platform. You'll need access to the

With that, you can start here --

### Configuring Settings

After registering a domain name for the competition, set `THIS_URL` (in `settings.py`) to that domain.

### Storage Buckets
Go to "Storage" on GCP console. A bucket for submissions should have been created (if not, instructions are in the infrastructure readme.)
Set up the CORS policy, which allows us to upload to the bucket on external websites. Find `docs/cors,json`; in there, update the domain URLs listed. Then, run `gsutil cors set path/to/cors.json gs://bc21-submissions` (updating the bucket name) to whatever it is this year.
Expand Down

0 comments on commit bccf21e

Please sign in to comment.