add multiple cross origin urls in spring boot

前端 未结 6 1224
太阳男子
太阳男子 2021-02-02 13:50

I found an example on how to set cors headers in spring-boot application. Since we have many origins, I need to add them. Is the following valid?

@Configuration
         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 14:00

    This would not work, try instead :

    registry.addMapping("/api/**")
            .allowedOrigins(
               "http://domain1.com",
               "http://domain2.com",
               "http://domain3.com")
    

    see also spring reference cors

提交回复
热议问题