AWS re:Post을(를) 사용하면 다음에 동의하게 됩니다. AWS re:Post 이용 약관

React routing not working on deployed application

0

Hello, I managed to deploy a Spring Boot with React application on AWS Elastic Beanstalk by packaging the application as a single .war archive, putting the frontend (React) build inside the target/classes/static folder. While locally everything works fine, when I try to login inside the newly deployed instance, the application is not able to redirect me to the main page after I put the login credentials, as it would do normally. The frontend console logs states that the redirect was indeed triggered (I used the useNavigate() React hook), but nothing happens as it stays on the same login page. Do you have any idea if it's something related to the S3 bucket not being able to serve the app properly? If I run the .war file locally on localhost:8080 it works by redirecting me to the new page.

질문됨 5달 전231회 조회
1개 답변
0
수락된 답변

I found the issue, apparently it was not related to AWS but to the way I set the cookie containing the JWT token that I'm using to make requests to the backend.

The issue was that the cookie was not saved on the browser when it got back with the login response and the private route that I'm using was redirecting me to the login page since it didn't find the cookie (as if I was not logged in). Locally it worked, but on the Elastic BeanStalk instance it didn't save the cookie since the connection was not HTTPS.

To overcome the issue and be able to save the cookie on the AWS instance, I sent it from the backend using a Set-Cookie header and also used the read-only property credentials: 'include' on each request I make (including the login one).

답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인