首页 > 其他分享 >allowedOrigins cannot contain the special value "*"

allowedOrigins cannot contain the special value "*"

时间:2023-08-22 17:33:24浏览次数:29  
标签:addMapping maxAge value cannot registry contain Override public allowedOrigins

Spring Boot的版本高于 2.4以后 ,原来的配置已经不适合目前的版本
将代码中的allowedOrigins改为allowedOriginPatterns


@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 跨域支持
     *
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                .allowCredentials(true)
                .maxAge(3600)
                .allowedHeaders("*");
    }

}

修改后

@Configuration
public class WebConfig implements WebMvcConfigurer {


    /**
     * 跨域支持
     *
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
                .allowCredentials(true)
                .maxAge(3600)
                .allowedHeaders("*");
    }

}

标签:addMapping,maxAge,value,cannot,registry,contain,Override,public,allowedOrigins
From: https://www.cnblogs.com/vipsoft/p/17649189.html

相关文章

  • IfcAppliedValue
    IfcAppliedValue实体定义此实体捕获由公式驱动的值,以及其他限定条件,包括单位基础、有效日期范围和分类。 IfcAppliedValue的范围由AppliedValue属性确定,该属性可以通过IfcApplizedValueSelect类型定义为IfcMeasureWithUnit或IfcMonetaryMeasure或IfcRatioMeasure。 (可选)If......
  • Container Runtime Intro
    https://www.tutorialworks.com/difference-docker-containerd-runc-crio-oci/......
  • 怎么解决“/usr/bin/ld: cannot find -lz: No such file or directory”
    这个错误是链接器无法找到所需的库文件-lz(通常是zlib库)导致的。-lz是编译器告诉链接器需要链接zlib库的标志。解决这个问题的方法是确保系统中安装了zlib库以及相关的开发包。在大多数Linux发行版中,你可以使用包管理工具来安装zlib库。例如,在Ubuntu中,你可以运行以......
  • 因为celcery项目而抛出的 not enough values to unpack (expected 3, got 0)解决方案
    python=36celery=226django=266在自己刚刚接触celery需要写定时任务的时候,按照大佬写的跑一遍的时候(https://blog.csdn.net/qq_36441027/article/details/123851915),发现自己跑的时候, 就会出现这么诡异的问题。解决办法:pipinstall eventlet 再去cmd里面执行cel......
  • Failed to execute 'btoa' on 'Window': The string to be encoded contains characte
    在使用浏览器内置APIbtoa()编码base64时:报错Failedtoexecute'btoa'on'Window':ThestringtobeencodedcontainscharactersoutsideoftheLatin1range报错信息解释:报错信息中指出字符串中包含了Latin1范围之外的字符,导致无法使用window.btoa进行解析。根据你提供......
  • 浅谈Angular模板指令:ng-template和ng-container的用法
    本篇文章带大家简单了解一下Angular模板的ng-template和ng-container指令,介绍一下ng-template和ng-container指令使用方法。ng-template指令简介ng-template是一个Angular结构型指令,用来渲染HTML。它永远不会直接显示出来。事实上,在渲染视图之前,Angular会把ng-template......
  • ValueError: setting an array element with a sequence.
    1.错误报错ValueError:settinganarrayelementwithasequence.Therequestedarrayhasaninhomogeneousshapeafter1dimensions.Thedetectedshapewas(12782,)+inhomogeneouspart.2.问题原因numpy版本问题:解决办法:卸载现有版本numpy,安装numpy1.21.0(python3.6)......
  • IfcCostValue
    IfcCostValue实体定义IfcCostValue是一个金额或影响金额的值。IfcCostValue的每个实例也可能有一个类别。可以识别出许多可能类型的成本价值。虽然人们对可能分配给不同类型成本的名称的含义有着广泛的理解,但对成本类型的命名没有通用标准,也没有任何广义的分类。以下定义了一......
  • Cause: java.sql.SQLException: Field 'id' doesn't have a default value Field 'id&
    报错内容: 是因为实体类文件中设置主键自增的类型不对导致的,建议再温习一下逐渐自增的类型以及使用方式我自己的实体类里面设置的IdType为auto,但是主键id是char类型的,还不是int数值类型,所以无法设置为自增 这里需要换成IdType.ID_WORKER_STR@ApiModelProperty(......
  • 如何为anaconda配置动态链接库——ERROR: compiler_compat/ld: cannot find
    现在为python编译lib库的环境主要是使用anaconda,而之前往往都是使用自编译python环境,然后使用Linux的系统lib环境,但是现在由于都是使用anaconda环境来编译python的扩展lib库,那么也就出现了为anaconda设置动态链接库这个问题了。 我们为Linux系统环境设置动态链接库地址的方式主......