錯誤:
when allowcredentials is true, allowedorigins cannot contain the special value "*"since that cannot be set on the "access-control-allow-origin" response header.
to allow credentials to a set of origins, list them explicitly or consider using "allowedoriginpatterns" instead.
我們沿用之前的配置檔案:
@configuration
public class globalcorsconfig implements webmvcconfigurer
}
前端請求就會報錯.
而提示的意思是:當設定allowcredentials為true,allowedorigins的值不能為特殊符號 ,因為在響應頭里不能設定"access-control-allow-origin" 的值為。解決辦法有兩個:
1. 顯式的列出allowedorigins具體值
2. 使用allowedoriginpatterns替代allowedorigins
@configuration
public class webconfig implements webmvcconfigurer
}
在我們程式的控制類中引入**@crossorigin** SpringBoot 2 4 0跨域問題
import org.springframework.context.annotation.configuration import org.springframework.web.servlet.config.annotation.corsregistry import org.springfra...
Spring Boot 2 4 0 發布說明
spring boot 2.4.0 正式版本不再新增 release 字尾宣告,在這個版本中增加了大量的新特性和改進,切記,不要輕易公升級 除了剛發布的spring boot 2.4.0,spring boot 2.3.x 2.2.x仍舊是活躍的維護的版本。spring boot遵循的是pivota...
springboot跨域配置
1.springboot它的好處就是它強大的自動配置,使我們能夠快速的搭建乙個專案。而springboot主要的設計目的是為微服務而誕生的。在前後端分離架構中,前端請求後端介面必然存在跨域,後端只需要提供服務即可。2.springboot配置跨域 編寫cors配置類 import org.sprin...