Class HttpServerConfiguration.CorsConfiguration

  • All Implemented Interfaces:
    io.micronaut.core.util.Toggleable
    Enclosing class:
    HttpServerConfiguration

    @ConfigurationProperties("cors")
    public static class HttpServerConfiguration.CorsConfiguration
    extends java.lang.Object
    implements io.micronaut.core.util.Toggleable
    Configuration for CORS.
    • Field Detail

      • DEFAULT_SINGLE_HEADER

        public static final boolean DEFAULT_SINGLE_HEADER
        See Also:
        Constant Field Values
      • DEFAULT_LOCALHOST_PASS_THROUGH

        public static final boolean DEFAULT_LOCALHOST_PASS_THROUGH
        See Also:
        Constant Field Values
    • Constructor Detail

      • CorsConfiguration

        public CorsConfiguration()
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface io.micronaut.core.util.Toggleable
        Returns:
        Whether cors is enabled. Defaults to false.
      • isLocalhostPassThrough

        public boolean isLocalhostPassThrough()
        Returns:
        Whether localhost pass-through is enabled. Defaults to false.
        Since:
        3.8.5
      • getConfigurations

        public java.util.Map<java.lang.String,​CorsOriginConfiguration> getConfigurations()
        Returns:
        The cors configurations
      • isSingleHeader

        public boolean isSingleHeader()
        Returns:
        Whether headers should be combined into a single header
      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets whether CORS is enabled. Default value (false)
        Parameters:
        enabled - True if CORS is enabled
      • setLocalhostPassThrough

        public void setLocalhostPassThrough​(boolean localhostPassThrough)
        Sets whether localhost pass-through is enabled. Default value false. Setting this to true will allow requests to be made to localhost from any origin.
        Parameters:
        localhostPassThrough - True if localhost pass-through is enabled
        Since:
        3.8.5
      • setConfigurations

        public void setConfigurations​(java.util.Map<java.lang.String,​CorsOriginConfiguration> configurations)
        Sets the CORS configurations.
        Parameters:
        configurations - The CORS configurations
      • setSingleHeader

        public void setSingleHeader​(boolean singleHeader)
        Sets whether CORS header values should be joined into a single header. Default value (false).
        Parameters:
        singleHeader - The single header flag