Friday, 14 May 2021

Flask-Session cookie works on other browsers for ip address & domain, but for chrome it only works on ip address

I found a question with this same problem, except it was 7 years old, and they had the opposite issue, where chrome worked for their domain, but not IP. I need this application to work on the domain, not the ip, which is unfortunate. If I Have some basic code like this: Flask:

app = Flask(__name__)
from dotenv import load_dotenv
load_dotenv()
SECRET_KEY = os.getenv('FLASK_APP_SECRET_KEY')
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)
CORS(app)

@app.route('/give', methods = ['GET'])
@cross_origin(supports_credentials=True)
def user_make(id):
    session['Hi'] = 'There'
    return 'ye'

@app.route('/take', methods = ['GET'])
@cross_origin(supports_credentials=True)
def user_load(id):
    return session['Hi']


reactjs:

let data = new FormData()
return axios
      .get('12.34.56.78' + '/give', data, {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      }).then(
return axios
      .take('12.34.56.78' + '/take', data, {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      }))
      

On a server with ip='12.34.56.78' and domain 'example.com': When using the domain or ip on safari, the output is

'there'

for both

however, on chrome, for ip the output is

'there'

however, for domain, the output is

Key Error

edit: Some more info: This is on an AWS ec2 ubuntu server, which is running on port 80 for the frontend and 5000 for the backend. I connected the ip address to the domain name with AWS Route 53... just in case this is relevant. To access the frontend, one can go to the ip or the domain, whereas to access the backend, one must go to ip:5000

Any more info needed?

Is this fixable? Thanks!



from Flask-Session cookie works on other browsers for ip address & domain, but for chrome it only works on ip address

No comments:

Post a Comment