yzcheng90 / X-SpringBoot

X-SpringBoot是一个轻量级的Java快速开发平台,能快速开发项目并交付【接私活利器】
2.3k stars 740 forks source link

打包部署跨域问题 #21

Closed greezi closed 4 years ago

greezi commented 4 years ago

打包成jar丢在服务器(端口8090)用jar运行的,x-springboot-ui 拷贝到服务器 nginx 按照demo配置的(监听8089端口),x-springboot-ui中common.js baseURL 直接写的服务器的ip加端口 跑起来提示跨域 Access to XMLHttpRequest at 'http://服务器IP:8090/token/login' from origin 'http://服务器IP:8089' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 请教一下大佬应该怎么配置呢?谢谢

yzcheng90 commented 4 years ago

如果nginx 8089端口 1、前台common.js baseURL就填nginx的 IP:8089
2、nginx 中配置一个路径(/pcui)挂载前台UI目录,前台common.js中的baseURL 中就不用填IP端口,直接填/pcui 最后访问 nginx的IP:8089 就可以了