浏览器控制台报错Failed to load module script:解决方法

浏览器控制台报错Failed to load module script:解决方法

在vue项目打包上传至服务器出现的报错。因为nginx转发路径问题,记录一下:
原本nginx直指向了一个前端项目,后来又加了一个,就直接复制的上一次的,导致变量名重复报的错

// 原来错误的代码,@router 变量名错误
location ^~/visitor/ {
	try_files $uri $uri/ @router;
	alias  /nsfocus/local/nginx/html/visitor/;
	index index.html;
}
location @router{
	rewrite ^.*$ /visitor/index.html last;
}

location ^~/seats/ {
	try_files $uri $uri/ @router;
	alias  /nsfocus/local/nginx/html/seats/;
	index index.html;
}
location @router{
	rewrite ^.*$ /seats/index.html last;
}
-----------------------------------------------------------------------------
// 正确配置,应该区分开来
location ^~/visitor/ {
	try_files $uri $uri/ @visitor_router;
	alias  /nsfocus/local/nginx/html/visitor/;
	index index.html;
}
location @visitor_router{
	rewrite ^.*$ /visitor/index.html last;
}

location ^~/seats/ {
	try_files $uri $uri/ @seats_router;
	alias  /nsfocus/local/nginx/html/seats/;
	index index.html;
}
location @seats_router{
	rewrite ^.*$ /seats/index.html last;
}

你可能感兴趣的:(nginx,前端部署,浏览器控制台报错)