我在前端有一个节点代理和角度。如果节点代理未运行,是否可以始终重定向到(服务器关闭!对不起!)一个有角页面?我不想让人们在没有节点代理启动的情况下看到其他更安全的页面。
我当时在考虑使用HTTP状态,但是有一些简单的方法吗?
谢谢!
$http
拦截器可以在全球范围内为您做到这一点
使用拦截器,您可以查看每个请求的响应。我建议使用HTTP状态,尤其是503“服务不可用”(服务器当前不可用(因为过载或为了维护而关闭)。通常,这是一个临时状态。)
$httpProvider.interceptors.push(function($location) {
var handleResponse = function(response) {
if(response.status === 503){
$location.path('/503.html'); // not sure if you are using ui-router or how your routing is set up...
}else{
return response;
}
};
return {
'response': handleResponse,
'responseError': handleResponse,
};
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句