使用Webpack和Angular Js时无法加载应用程序

时间:2017-10-25 09:45:56

标签: angularjs webpack webpack-dev-server

我的初始页面将从webpack-dev-server呈现,一旦接受凭据,我的应用程序将被加载。我无法运行应用程序但面临此错误。

Uncaught SyntaxError: Unexpected token <

My folder structure

在Html页面显示错误

This is error on html page

这是我的webpack服务器代码

devServer: {
        contentBase: path.join(__dirname, "./dist"),
        compress: true,
        port: 3443,
        before: function(app){
            app.use(proxy(['/api', '/login', '/logout'], {
                    target: 'https://' + dest + 'log/',
                    changeOrigin: true,
                    secure: true,
                    onProxyReq: function (proxyReq, req, res) {

                        //console.log(req.url);
                        if (req.url === '/login') {
                            token = "";
                        }
                        if (token) {
                            proxyReq.setHeader('token', token);
                        }
                    },
                    onProxyRes: function (proxyRes, req, res) {
                        if (proxyRes.statusCode == '403') {
                            proxyRes.headers['location'] = 'http://localhost:3443/login';
                        } else {
                            var _locHeader = proxyRes.headers['location'];
                            if (_locHeader && _locHeader.indexOf(dest) > -1) {
                                proxyRes.headers['location'] = 'http://localhost:3443/';
                            }
                            var proxyCookie = proxyRes.headers["set-cookie"];
                            if (proxyCookie) {
                                cookies = proxyCookie;
                                setToken();
                            }
                        }

                    },
                    cookieDomainRewrite: true
                }))
        },
        historyApiFallback: true
    },

0 个答案:

没有答案