后端已经部署在远程服务器使用 nginx 映射
后端部署在 8090, nginx使用 8089映射
浏览器url, 或 ajax 能够请求。
Vue axios打包后无法请求,打包前配置vue代理可以请求
报错
如果你的前端项目部署在8089端口,然后又将8089端口所监听到的请求全部代理到8090端口明显是不对的,这样没办法区分哪些是前端请求哪些是后端请求。
后端请求加这个试试 @CrossOrigin
或者
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CrossOriginConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedHeaders("*")
.allowedMethods("*")
.allowCredentials(true);
WebMvcConfigurer.super.addCorsMappings(registry);
}
}
不知道你这个问题是否已经解决, 如果还没有解决的话:浏览器输入server_name配置的地址加80 ,显示welcome,已经配置成功