Set to always allow any origin to open app websocket.
This commit is contained in:
		
							parent
							
								
									ac7d040b5e
								
							
						
					
					
						commit
						ad18c1b3d4
					
				|  | @ -3,14 +3,11 @@ package nl.andrewl.railsignalapi.live.websocket; | ||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||||
| import org.springframework.core.env.Environment; |  | ||||||
| import org.springframework.web.socket.config.annotation.EnableWebSocket; | import org.springframework.web.socket.config.annotation.EnableWebSocket; | ||||||
| import org.springframework.web.socket.config.annotation.WebSocketConfigurer; | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; | ||||||
| import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration; | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration; | ||||||
| import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; | ||||||
| 
 | 
 | ||||||
| import java.util.Set; |  | ||||||
| 
 |  | ||||||
| /** | /** | ||||||
|  * Configuration for Rail Signal's websockets. This includes both app and |  * Configuration for Rail Signal's websockets. This includes both app and | ||||||
|  * component connections. |  * component connections. | ||||||
|  | @ -24,7 +21,6 @@ public class WebsocketConfig implements WebSocketConfigurer { | ||||||
| 	private final ComponentWebsocketHandshakeInterceptor componentInterceptor; | 	private final ComponentWebsocketHandshakeInterceptor componentInterceptor; | ||||||
| 	private final AppWebsocketHandler appHandler; | 	private final AppWebsocketHandler appHandler; | ||||||
| 	private final AppWebsocketHandshakeInterceptor appInterceptor; | 	private final AppWebsocketHandshakeInterceptor appInterceptor; | ||||||
| 	private final Environment env; |  | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | 	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | ||||||
|  | @ -33,12 +29,6 @@ public class WebsocketConfig implements WebSocketConfigurer { | ||||||
| 				.addInterceptors(componentInterceptor); | 				.addInterceptors(componentInterceptor); | ||||||
| 		WebSocketHandlerRegistration appHandlerReg = registry.addHandler(appHandler, "/api/ws/app/*") | 		WebSocketHandlerRegistration appHandlerReg = registry.addHandler(appHandler, "/api/ws/app/*") | ||||||
| 				.addInterceptors(appInterceptor); | 				.addInterceptors(appInterceptor); | ||||||
| //		appHandlerReg.setAllowedOrigins("*"); | 		appHandlerReg.setAllowedOrigins("*"); | ||||||
| 		// If we're in a development profile, allow any origin to access the app websocket. |  | ||||||
| 		// This is so that we can use a standalone JS dev server. |  | ||||||
| 		if (Set.of(env.getActiveProfiles()).contains("development")) { |  | ||||||
| 			log.info("Allowing all origins to access app websocket because development profile is active."); |  | ||||||
| 			appHandlerReg.setAllowedOrigins("*"); |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue