Vue 路由 Nginx 配置

发布时间: 更新时间: 总字数:97 阅读时间:1m 作者: IP属地: 分享 复制网址

vueRouterMode 支持配置为 historyhash,当配置为 history 时,若访问地址会报 404 的错误,此时需要配置 nginx 实现路由转发规则

nginx 配置

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	location / {
		add_header Cache-Control 'no-store, no-cache';
		root   /data/ui/;
		index  index.html;
		try_files   $uri $uri/ /index.html;
	}

	location /api/ {
		proxy_pass http://localhost:8000;
	}

	# You may need this to prevent return 404 recursion.
	location = /404.html {
		internal;
	}
}
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数