Skip to content

Commit

Permalink
Merge pull request #295 from HelsinkiUniCollab/jonij/fix-cors-issues
Browse files Browse the repository at this point in the history
Jonij/fix cors issues
  • Loading branch information
smannist committed Aug 21, 2023
2 parents c19ff32 + e19360c commit cf45774
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
- name: Setup .env file for frontend
run: echo "REACT_APP_BACKEND_URL=${{ secrets.REACT_APP_BACKEND_URL }}" > ./recommender-front/.env.local
- name: Setup .env file for backend
run: echo "REACT_APP_BACKEND_URL=${{ secrets.REACT_APP_BACKEND_URL }}" > ./recommender-back/.env && echo "MONGO_URI=${{ secrets.MONGO_URI }}" >> ./recommender-back/.env
run: |
echo "REACT_APP_BACKEND_URL=${{ secrets.REACT_APP_BACKEND_URL }}" > ./recommender-back/.env
echo "MONGO_URI=${{ secrets.MONGO_URI }}" >> ./recommender-back/.env
echo "FLASK_DEBUG=False" >> ./recommender-back/.env
- name: Build and push frontend
uses: docker/build-push-action@v2
with:
Expand Down
14 changes: 3 additions & 11 deletions docs/pouta.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ $ sudo docker container prune
# Remove all of the containers and images
$ sudo docker rm -f $(docker ps -a -q)
$ sudo docker rmi -f $(docker images -a -q)

# create ubuntu_default network it it's removed
$ sudo docker create network ubuntu_default
```

## Removing old Docker images in Pouta
Expand Down Expand Up @@ -168,17 +171,6 @@ http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 120s;

# Add CORS headers
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000 always;
add_header 'Content-Type' 'text/plain charset=UTF-8' always;
add_header 'Content-Length' 0 always;
return 204;
}

add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
}

location / {
Expand Down
1 change: 1 addition & 0 deletions generate_local_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cat > ./recommender-back/.env << EOF
REACT_APP_BACKEND_URL=http://localhost:5000
DEVELOPMENT_DB_URI="$1"
CACHE_MODE="simple"
FLASK_DEBUG="True"
# Include the 'recommender-back' directory in the PYTHONPATH.
PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/recommender-back"
Expand Down
2 changes: 1 addition & 1 deletion recommender-back/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CACHE_TYPE = 'redis'

config = {
"DEBUG": True,
"DEBUG": os.environ.get('FLASK_DEBUG', 'False').lower() == 'true',
"CACHE_TYPE": CACHE_TYPE,
"CACHE_REDIS_URL": Config.CACHE_REDIS_URL,
"CACHE_DEFAULT_TIMEOUT": 3600
Expand Down

0 comments on commit cf45774

Please sign in to comment.