public static String defaultOrigin ( HttpServerExchange exchange ) { String host = NetworkUtils . formatPossibleIpv6Address ( exchange . getHostName ( ) ) ; String protocol = exchange . getRequestScheme ( ) ; int port = exchange . getHostPort ( ) ; //This browser set header should not need IPv6 escaping StringBuilder allowedOrigin = new StringBuilder ( 256 ) ; allowedOrigin . append ( protocol ) . append ( "://" ) . append ( host ) ; if ( ! isDefaultPort ( port , protocol ) ) { allowedOrigin . append ( ' ' ) . append ( port ) ; } return allowedOrigin . toString ( ) ; }
Determine the default origin to allow for local access .