Move a wildcard SockJS allowed origin to setAllowedOriginPatterns
ProprietaryA SockJS endpoint that allows the "*" origin fails from Spring Framework 5.3 on. AbstractSockJsService sets setAllowCredentials(true) on the service's CORS configuration unconditionally, and the service is a CorsConfigurationSource, so CorsConfiguration.checkOrigin runs validateAllowCredentials() and throws IllegalArgumentException for a wildcard origin. Moves the wildcard to setAllowedOriginPatterns, which 5.3 added for this case and which both the SockJS transport requests and the WebSocket handshake honour: AbstractWebSocketHandlerRegistration passes the patterns on to OriginHandshakeInterceptor, which keeps them in a CORS configuration of its own. Only an endpoint that calls withSockJS() is changed, because a plain WebSocket endpoint builds no CORS configuration and a wildcard origin on it remains valid. An origin given by a variable or a constant is left alone, since nothing proves it is the wildcard.
io. moderne. java. spring. framework. MigrateSockJsAllowedOriginsWildcardmod run . --recipe= io. moderne. java. spring. framework. MigrateSockJsAllowedOriginsWildcardInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.