Something that's critical to our microservice-based social media platform is sharing the session details when putting things together. When we load the main page, it may have to pull together bits of data from multiple places. This means that after logging in to the system, the session ID that is generated has to be passed along seamlessly.
Spring Cloud Gateway can forward various requests, but Spring Session has a lazy approach to things. This means, we need to step up and save the session immediately; otherwise, the first few remote calls might fail.
To do so, we need to create a custom Spring Cloud Gateway filter as follows:
@Configuration public class GatewayConfig { private static final Logger log = LoggerFactory.getLogger(GatewayConfig.class); /** * Force the current WebSession...