3

I am developing an application with a springboot backend and an angular frontend.

Both will be deployed under the same domain. So I will use cookies to maintain the session.

But for development the spring services backend is on localhost:8080 and the angular app is on localhost:4200

I would like to be able to share the cookie on localhost for the different ports. How can I do this?

When I make a call to localhost:8080/api/service I can see in the response a Set-Cookie: JSESSIONID=A2DD58970CB3E8B9DD4F3BF1444D5E55; Path=/api; HttpOnly But on the next call the cookie is not sent.

I have decided to use cookies instead of sending a token in the header after reading this guide.

I don't have any strange configuration, but I understand that it must be due to a security problem. how can I disable this security control for development? What do you do in such cases?

1 Answer 1

3

I have managed to fix it

From angular side using this.http.get('http://...', { withCredentials: true })

From spring side adding cors configuration with .allowCredentials(true)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.