If the baseURL of axios is set to localhost, it can be changed from cookie, to IP, but the backend of cookie, cannot be used, but the cookie can be obtained.

Front

const axios = Axios.create({
  baseURL: "http://localhost:8066",   cookie
  // baseURL: "http://192.168.1.107:8066", cookie
  withCredentials:true,
  timeout: 5000,
});

when baseURL is set to native IP, you cannot carry cookie, but the backend can get cookie

.

backend code
configure

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //
        registry.addMapping("/**")
                //
                .allowedOrigins("*")
                //.allowedOrigins("http://localhost:8080")
                // 
                .allowCredentials(true)
                //
                .allowedMethods("*")
                //
                .maxAge(3600);
    }
}

all tried, there is no difference

 .allowedOrigins("*").allowedOrigins("http://localhost:8080")

write cookie:

public static void writeCookie(HttpServletResponse response, String cookieName, String value) {
    Cookie cookie = new Cookie(cookieName, value);
    cookie.setPath("/");
    cookie.setMaxAge(3000 * 60);
    response.addCookie(cookie);
}
Jun.03,2021

found the problem, because I entered

in the address bar when I visited the front-end project.

http://localhost:8080/

just change the address bar to ip
http://192.168.1.107:8080/

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9dbfd-1983.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9dbfd-1983.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?