如何配置路由器以处理xhr并将请求定向到api。
使用案例:文件下载
我有RESTAPI
我试图使用<a>
操作链接标记下载文件 - &gt;单击解析为具有绝对URL的新选项卡/窗口。
我的webApp正在http://localhost:4200 proxying request
到http://localhost:44226投放
当我尝试使用网址http://localhost:4200/api/download/files/1点击api下载文件时
我收到错误:
无法识别的BULError:/ api / download / files / 1
const Router = Ember.Router.extend({
location: config.locationType // auto
});
Router.map(function() {
this.route('login');
this.route('logout');
});
export default Router;
任何指示如何继续/改变什么。
答案 0 :(得分:2)
我通常在我的Ember应用和API服务器前使用nginx。这提供了使用表达式匹配URL然后 - 代理API或Ember应用程序的路由。以下是添加特殊网址以供下载的示例https://gitlab.com/pixelhandler/xyz-conf/blob/master/qayaq.local我将通过nginx添加添加规则。