angular 应用程序 运行 时 REST 客户端停止
REST client is stopped when angular application running
在我的应用程序中,我使用了一个 REST 客户端和一个由 composer-cli 生成的 Angular 应用程序。有时,REST 客户端会在我使用 Angular 应用程序时终止。
我注意到这种终止会发生,尤其是当我尝试在 Angular 应用程序中使用图像时。加载图像时,似乎向 REST 客户端发送了不需要的请求。
REST客户端日志如下。
我使用的是默认生成的 Angular 应用程序。有什么建议吗?
我在我的代码中发现了这个问题。它位于自动生成的代理配置文件 (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';
}
}
}];
我把上面的部分改成了,
module.exports = [{
context: ['/auth', '/api'],
target,
secure: true,
changeOrigin: true
}];
而且图片应该位于 ./src/assets
文件夹中。
在我的应用程序中,我使用了一个 REST 客户端和一个由 composer-cli 生成的 Angular 应用程序。有时,REST 客户端会在我使用 Angular 应用程序时终止。
我注意到这种终止会发生,尤其是当我尝试在 Angular 应用程序中使用图像时。加载图像时,似乎向 REST 客户端发送了不需要的请求。
REST客户端日志如下。
我使用的是默认生成的 Angular 应用程序。有什么建议吗?
我在我的代码中发现了这个问题。它位于自动生成的代理配置文件 (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';
}
}
}];
我把上面的部分改成了,
module.exports = [{
context: ['/auth', '/api'],
target,
secure: true,
changeOrigin: true
}];
而且图片应该位于 ./src/assets
文件夹中。