angular-17-jwt-auth
angular-17-jwt-auth copied to clipboard
HttpOnly not working
I have followed your spring boot 3 and angular 17 JWT tutorial. Everything is working fine except JWT.
- I am able login, and refresh token is created
- I am able to see httpOnly cookie in my frontend response
- but for subsequent requests token is not being sent to backend
- backend it shows "AnonymousUser"
Hi, before running the backend server, you need to add minor configuration:
/* In AuthController.java */
// @CrossOrigin(origins = "*", maxAge = 3600)
@CrossOrigin(origins = "http://localhost:8081", maxAge = 3600, allowCredentials="true")
/* In TestController.java */
// @CrossOrigin(origins = "*", maxAge = 3600)
@CrossOrigin(origins = "http://localhost:8081", maxAge = 3600, allowCredentials="true")