这是我在本地环境中遇到的2个错误的摘要,当我在浏览器中单击直接URL时-托管版本中未发生此错误。对于托管,我使用了AWS S3,在404和403错误上,我重定向到状态为200的index.html文件。
我尝试过 1. Angularjs文档为CSP建议的ng-csp =“ no-inline-style; no-unsafe-eval” 2.签出了大量资源来修复gulpfile.js中的gulp和浏览器同步js代码 3.我也尝试按照github angular issue 1213
中的建议尝试$ route.reload()。这是我的index.html和gulpfile.js代码
<!-- <!DOCTYPE html> -->
<html lang="en" ng-app="wealth-desk" ng-csp="no-inline-style;no-unsafe-eval" flow-init>
<base href="/">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link href="assets/img/favicon.ico" rel="shortcut icon" type="image/x-icon">
<!-- css file loading -->
</head>
<body>
<ng-view autoscroll="true"></ng-view>
</body>
<!-- Latest compiled and minified JavaScript -->
<script type="text/javascript" src="assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/slick.min.js"></script>
<!-- Angular Dependencies -->
<script type="text/javascript" src="assets/js/angular.min.js"></script>
<script type="text/javascript" src="assets/js/angular-route.min.js"></script>
<script type="text/javascript" src="assets/js/angular-resource.min.js"></script>
<script type="text/javascript" src="assets/js/angular-animate.min.js"></script>
<script type="text/javascript" src="assets/js/angular-aria.min.js"></script>
<script type="text/javascript" src="assets/js/angular-messages.min.js"></script>
<script type="text/javascript" src="assets/js/angular.slick.js"></script>
<!-- more js files of my application - related to angular loading -->
</html>
Gulpfile.js
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var browserSync = require('browser-sync').create();
var environments = require('gulp-environments');
var development = environments.development;
var production = environments.production;
/** load config file based on enviroment */
var configFile = production() ? "./src/env/prod.js" : "./src/env/dev.js";
gulp.task('lint', function () {
return gulp.src('./src/app/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build', ['lint']);
gulp.task('browser-sync', ['build'], function () {
browserSync.init({
server: {
baseDir: "./src",
// The key is the url to match
// The value is which folder to serve (relative to your current working directory)
routes: {
"/bower_components": "bower_components",
"/node_modules": "node_modules"
}
},
browser: "chrome"
});
});
gulp.task('default', ['browser-sync'], function () {
gulp.watch("./src/**/*.*", ["build"]);
gulp.watch("./src/**/*.*", browserSync.reload);
})