I am encountering an issue when deploying my Flask app on the Render platform. Locally, the application runs successfully, but upon deployment, I am facing the following error:
AttributeError: 'module' object has no attribute 'encode'
The error is specifically pointing to the line where I use the jwt.encode function. Here is the relevant code snippet:
def create_access_token(data: dict, expires_delta: timedelta):
to_encode = data.copy()
expire = datetime.utcnow() + expires_delta
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm="HS256")
return encoded_jwt
I have verified that the jwt module is installed both locally and on the Render platform. Locally, the application works without any issues. However, on Render, I am encountering this attribute error.