打包vue项目
npm run build
得到一个dist文件
上传至服务器
新建一个.conf文件
server {
listen 8084;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-Origin' *;
#允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
#允许请求的方法,比如GET/POST/PUT
add_header 'Access-Control-Allow-Methods' *;
#允许请求的header
add_header 'Access-Control-Allow-Headers' *;
location / {
root /usr/local/vue/fruit/dist/;
#proxy_pass http://localhost:8181;
#root html;
index index.html index.html;
}
}