REST client is stopped when angular application ru

2019-09-03 09:58发布

In my application, I'm using a REST client and an Angular application generated by composer-cli. In sometimes, the REST client is terminated while I'm using the Angular app.

I noticed that this termination happens especially whenever I'm trying to use images in the Angular app. It seems an unwanted request is sent to the REST client when the image is loading.

REST client's log is as below.

enter image description here

I'm using a default generated Angular app. Any suggestions?

1条回答
ら.Afraid
2楼-- · 2019-09-03 10:55

I figured out the issue in my code. It was in the auto-generated proxy configuration file (proxy.conf.js).

module.exports = [{
    context: ['/auth', '/api'],
    target,
    secure: true,
    changeOrigin: true
}, {
    context: '/',
    target,
    secure: true,
    changeOrigin: true,
    ws: true,
    bypass: function (req, res, proxyOptions) {
        const accept = req.headers.accept || '';
        if (accept.indexOf('html') !== -1) {
            return '/index.html';
        }
    }
}];

I changed above part to,

module.exports = [{
    context: ['/auth', '/api'],
    target,
    secure: true,
    changeOrigin: true
}];

and also images should be located in ./src/assets folder.

查看更多
登录 后发表回答