My front-end project is nuxt3
The console prints and reports a crossing problem, so we can only change the back-end springboot
Solution: Add configuration class CorsConfig
package com.xxx.config;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry){
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedHeaders(CorsConfiguration.ALL)
.allowedMethods(CorsConfiguration.ALL)
.allowCredentials(true)
.maxAge(3600);
}
}