Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

示例工程本地预览没问题,部署到Nginx,按照文档配置,停留在初始页面转圈? #1206

Closed
ZYMain opened this issue Jul 7, 2021 · 7 comments
Labels
bug 🐛 Something isn't working question Further information is requested

Comments

@ZYMain
Copy link

ZYMain commented Jul 7, 2021

如题
https://github.com/vueComponent/ant-design-vue-pro.git
直接clone到本地的工程
npm install
npm run serve (本地预览正常)
npm run build (打包正常)

打包后的dist文件夹上传到服务器,按文档配置了nginx配置,始终首页转圈圈,报错
image

image

nginx配置我贴出来,求帮助,网上说什么给vueConfig里添加publicPath: './',把history改成hash,还有说什么非根目录,我都尝试了,还是一样的问题

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

   root /dist;

   location / {
   	  try_files $uri $uri/ /index.html;
   }

   location /api {
	  proxy_set_header   X-Forwarded-Proto $scheme;
       proxy_set_header   Host              $http_host;
       proxy_set_header   X-Real-IP         $remote_addr;
       proxy_pass   https://preview.pro.antdv.com; 
   }

   error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

@ZYMain ZYMain added the question Further information is requested label Jul 7, 2021
@sendya
Copy link
Member

sendya commented Jul 7, 2021

不要修改 publicPath

@sendya sendya closed this as completed Jul 7, 2021
@sendya sendya reopened this Jul 7, 2021
@TjFish
Copy link

TjFish commented Jul 9, 2021

遇到同样问题,未对代码做任何修改,直接npm run build 部署到nginx 后一直转圈,显示堆栈溢出

@TjFish
Copy link

TjFish commented Jul 9, 2021

遇到同样问题,未对代码做任何修改,直接npm run build 部署到nginx 后一直转圈,显示堆栈溢出
image

@wn90674
Copy link

wn90674 commented Jul 11, 2021

今天部nginx的时候也遇到了,折腾了一番,暂时是先把vue.config.js中 vue的externals 注释掉了

const assetsCDN = {
  // webpack build externals
  externals: {
    // vue: 'Vue',
    'vue-router': 'VueRouter',
    vuex: 'Vuex',
    axios: 'axios'
  },
  css: [],
  // https://unpkg.com/browse/vue@2.6.10/
  js: [
    // '//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js',
    '//cdn.jsdelivr.net/npm/vue-router@3.1.3/dist/vue-router.min.js',
    '//cdn.jsdelivr.net/npm/vuex@3.1.1/dist/vuex.min.js',
    '//cdn.jsdelivr.net/npm/axios@0.19.0/dist/axios.min.js'
  ]
}

@FrozenYogurtPuff
Copy link

似乎是 7 月 1 日的 commit 引入 vue-drags 的问题,把这个 commit revert 回去之后就正常了。本人非前端,具体怎么解决循环依赖不清楚,暂时是这么解决的。

@sendya
Copy link
Member

sendya commented Jul 12, 2021

似乎是 7 月 1 日的 commit 引入 vue-drags 的问题,把这个 commit revert 回去之后就正常了。本人非前端,具体怎么解决循环依赖不清楚,暂时是这么解决的。

测了一下啊,应该是这个引起的,具体还没查到

@sendya
Copy link
Member

sendya commented Jul 12, 2021

把那个 pr 回退了。更新一下重新 pull 新代码 build 就能正常运行了

@sendya sendya closed this as completed Jul 12, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug 🐛 Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants