Skip to content

Commit

Permalink
💚 fix: update cors
Browse files Browse the repository at this point in the history
  • Loading branch information
megasanjay committed Oct 19, 2023
1 parent 9e82f3e commit 39c0b71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apis/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def validate_is_valid_email(instance):
resp = make_response(user.to_dict())

resp.set_cookie(
"token", encoded_jwt_code, secure=True, httponly=True, samesite="lax"
"token", encoded_jwt_code, secure=True, httponly=True, samesite="None"
)
resp.status_code = 200

Expand Down Expand Up @@ -359,7 +359,7 @@ def post(self):
"",
secure=True,
httponly=True,
samesite="lax",
samesite="None",
expires=datetime.datetime.now(timezone.utc),
)
resp.status_code = 204
Expand Down
11 changes: 6 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Entry point for the application."""
import datetime
import importlib
import logging
import os
from datetime import timezone

import logging
import jwt
from flask import Flask, request
from flask_bcrypt import Bcrypt
Expand Down Expand Up @@ -69,7 +69,8 @@ def create_app(config_module=None):
"/*": {
"origins": [
"http://localhost:3000",
"https://staging.fairhub.io",
"https:\/\/brave-ground-.*-.*.centralus.2.azurestaticapps.net", # noqa E501 # pylint: disable=line-too-long # pylint: disable=anomalous-backslash-in-string
"https://fairhub.io",
],
}
},
Expand Down Expand Up @@ -163,7 +164,7 @@ def on_after_request(resp):
"",
secure=True,
httponly=True,
samesite="lax",
samesite="None",
expires=datetime.datetime.now(timezone.utc),
)
return resp
Expand All @@ -179,13 +180,13 @@ def on_after_request(resp):
config.FAIRHUB_SECRET,
algorithm="HS256",
)
resp.set_cookie("token", new_token, secure=True, httponly=True, samesite="lax")
resp.set_cookie("token", new_token, secure=True, httponly=True, samesite="None")

app.logger.info("after request")
app.logger.info(request.headers.get("Origin"))

resp.headers["Access-Control-Allow-Origin"] = request.headers.get("Origin")
# resp.headers["Access-Control-Allow-Credentials"] = "true"
resp.headers["Access-Control-Allow-Credentials"] = "true"
# resp.headers[
# "Access-Control-Allow-Headers"
# ] = "Content-Type, Authorization, Access-Control-Allow-Origin,
Expand Down

0 comments on commit 39c0b71

Please sign in to comment.