问题一:https跨域问题
下面举了三个前后端分离项目的例子,配置都差不多,只不过我想写详细一些给你们看,因为我配置第一个项目的时候还好,但是配置第二个项目遇到了一些问题。所以多写几个例子,方便大家看的明白一些。
修改vue项目中 config 下的 index.js 配置文件,加上代理
dev: {
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': { //代理标识
target: 'http://localhost:8888',
changeOrigin: true, // 允许跨域
secure: false,
pathRewrite: {
'^.api': '/'
}
},
'/apis': { //代理标识
target: 'http://localhost:8889',
changeOrigin: true, // 允许跨域
secure: false,
pathRewrite: {
'^.apis': '/'
}
},
'/apiss': { //代理标识
target: 'http://localhost:8887',
changeOrigin: true, // 允许跨域
secure: false,
pathRewrite: {
'^.apiss': '/'
}
},
}
打开Linux上的安装的nginx下的目录,对nginx.conf文件进行修改
在server 443里面进行修改
server {
listen 443 ssl;
server_name www.upahead.cn;
root /www/wwwroot/upahead.cn;#前端文件存放地址(官网 前端文件存放地址)
index index.html index.htm;
ssl_certificate cert/cert_file_name.pem;
ssl_certificate_key cert