Skip to content

Commit

Permalink
Merge pull request #23 from souravs17031999/bugfix/fix-CORS-error
Browse files Browse the repository at this point in the history
Fix CORS issue for preflight requests
  • Loading branch information
souravs17031999 authored Dec 4, 2022
2 parents 23bbe20 + d6bd1fb commit 7e0e55b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ local:
@echo "MAKE local ==========================================="

docker-compose down
LOG_LEVEL=DEBUG PGHOST=postgres PGUSER=postgres PGPASSWORD=DHANPURA8 PGDATABASE=dev REQUIRE_DB_INSERT=False POSTGRES_PASSWORD=DHANPURA8 POSTGRES_DB=dev POSTGRES_USER=postgres ALLOWED_ORIGIN_HOST_PROD=* REQUIRE_DB_MIGRATIONS=0 REQUIRE_DB_INSERT=0 SENDGRID_API_KEY_PROD=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 REDIS_URL=redis://default:xe7QUk67TJwBDJHMXwHHreBSVrrFxsxCN6mkm5dG@redis:6379/0 NOTIFICATION_INTERNAL_URL=http://notification_service:8084 OIDC_CONFIG="{\"server_url\": \"https://keycloak-opioner.onrender.com/auth/realms/OPIONER\", \"issuer\": \"https://keycloak-opioner.onrender.com/auth/realms/OPIONER\", \"audience\": \"account\"}" docker-compose up --build
LOG_LEVEL=DEBUG PGPORT=5432 PGHOST=postgres PGUSER=postgres PGPASSWORD=DHANPURA8 PGDATABASE=dev REQUIRE_DB_INSERT=False POSTGRES_PASSWORD=DHANPURA8 POSTGRES_DB=dev POSTGRES_USER=postgres ALLOWED_ORIGIN_HOST_PROD=* REQUIRE_DB_MIGRATIONS=0 REQUIRE_DB_INSERT=0 SENDGRID_API_KEY_PROD=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 REDIS_URL=redis://default:xe7QUk67TJwBDJHMXwHHreBSVrrFxsxCN6mkm5dG@redis:6379/0 NOTIFICATION_INTERNAL_URL=http://notification_service:8084 OIDC_CONFIG="{\"server_url\": \"https://keycloak-opioner.onrender.com/auth/realms/OPIONER\", \"issuer\": \"https://keycloak-opioner.onrender.com/auth/realms/OPIONER\", \"audience\": \"account\"}" docker-compose up --build
11 changes: 5 additions & 6 deletions notification-service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ def before_request_func():
logger.info("REQUEST METHOD: %s", request.method)
logger.info("REQUEST HEADERS: %s", request.headers)

if request.method == "GET":
logger.info("REQUEST PARAMS: %s", request.args)
elif request.method == "POST":
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)
logger.info("REQUEST PARAMS: %s", request.args)
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)

return authorize_request(request.headers)
if request.method != "OPTIONS":
return authorize_request(request.headers)


@app.after_request
Expand Down
11 changes: 5 additions & 6 deletions product-service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ def before_request_func():
logger.info("REQUEST METHOD: %s", request.method)
logger.info("REQUEST HEADERS: %s", request.headers)

if request.method == "GET":
logger.info("REQUEST PARAMS: %s", request.args)
elif request.method == "POST":
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)
logger.info("REQUEST PARAMS: %s", request.args)
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)

return authorize_request(request.headers)
if request.method != "OPTIONS":
return authorize_request(request.headers)


@app.after_request
Expand Down
14 changes: 6 additions & 8 deletions user-service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ def before_request_func():
logger.info("REQUEST METHOD: %s", request.method)
logger.info("REQUEST HEADERS: %s", request.headers)

if request.method == "GET":
logger.info("REQUEST PARAMS: %s", request.args)
elif request.method == "POST":
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)
logger.info("REQUEST PARAMS: %s", request.args)
logger.info("REQUEST PARAMS: %s", request.data)
logger.info("REQUESTED FILES: %s", request.files)

return authorize_request(request.headers)
if request.method != "OPTIONS":
return authorize_request(request.headers)


@app.after_request
Expand Down Expand Up @@ -116,9 +115,8 @@ def decode_auth_token(auth_token):
except jwt.InvalidSignatureError:
logger.error('Signature verification failed. Please log in again.')
return SIGNATURE_VERIFICATION_FAILED
except Exception as e:
except jwt.InvalidTokenError:
logger.error('Invalid token. Please log in again.')
logger.error('Error: %s', e)
return INVALID_TOKEN

def get_public_key_server():
Expand Down

0 comments on commit 7e0e55b

Please sign in to comment.