I recently finished building a full-stack Library Management System, with:
- ๐ฅ๏ธ Frontend in React, deployed on Vercel
- ๐ง Backend in Spring Boot, deployed on Railway
At the start, I was excited. But then... deployment hit me like a wall.
๐งฉ The Struggles
I didn't know:
- How to deploy the backend and frontend separately
- How to set up CORS and cookies properly
- Why my app worked in Firefox, but failed with 401 errors in Chrome
I tried debugging:
- Spring Security
- Session management
- Axios headers and cookies
I even rewrote parts of my code, thinking the problem was in my auth flowโฆ
Turns out, Chrome had third-party cookies disabled. ๐ค
Three. Days. Gone.
๐ What I Learned
Spring Security from Scratch
I learned how to create aSecurityFilterChainand handle login with session-based auth using a custom success handler.Backend over LocalStorage
Initially, I was storing the user inlocalStorageand using it for validation.
I later replaced this with a backend call to/check-auth, making it more secure and reliable.CORS + Cookie Configuration
.allowedOrigins("https://my-frontend.vercel.app")
.allowCredentials(true)
Axios:
withCredentials: true
- Cookie Headers
SameSite=NoneSecureHttpOnly
All crucial for cross-origin session persistence.
โ Final Setup
- ๐ Frontend: React + Vercel
- ๐ง Backend: Spring Boot + Railway
- ๐ Auth: Session-based, cookie-secured
- ๐ง Learned: Spring Security, Session Auth, CORS, Deployment practices
๐ฏ Next Goal
Now that itโs stable, Iโm planning to migrate the backend to AWS EC2 for a more production-like deployment.
Wish me luck ๐ค
If youโve ever been stuck debugging for days over something silly โ youโre not alone. Keep going. It clicks eventually โจ
#SpringBoot #ReactJS #WebDev #FullStack #SpringSecurity #Debugging #AWS #DevJourney
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.