1. Communication Issue between Frontend and Backend:
- The backend had implemented various validations for the request body data in the Create API (e.g., the
choice_url must be in URI format, the choices array must contain more than 2 objects, the number of objects in the choices array must be even, etc.). However, the frontend team was not informed about these validations, causing them to encounter continuous errors. It is important to diligently document the API specifications and effectively communicate these requirements to the frontend team.
2. Access/Refresh Token Not Working in Production:
- The access and refresh tokens were functioning properly in the development environment but stopped working when deployed. It was discovered that the issue was related to case sensitivity in the cookies. The variables sent in camel case from the frontend were being transformed to lowercase in the headers when they returned to the server. This caused a mismatch with the camel case variables expected by the authentication middleware. To resolve this, the variables were converted to lowercase.
- During testing on the server, the login controller was sending the response as a cookie, and the authentication middleware was expecting the request as a cookie. However, on the frontend, the cookie received from the controller was being sent in the headers to the authentication middleware. This issue was resolved by changing
req.cookies to req.headers to match the frontend behavior.
- To ensure that the code works in both frontend and backend environments without modification, a ternary operator was used to differentiate between receiving values as headers (frontend) and as cookies (backend).