Ember-cli ProxyPass

问题描述 投票:3回答:1

我正在使用ember-cli开发一个应用程序,它需要使用ProxyPass向服务器发送http请求。

我的服务器如下所示:subdomain.domain.com/api/clients/users和Ember-cli默认创建http:// localhost:4200 /

我试着在我的http.conf中这样做:

ProxyPass /api/clients http://subdomain.domain.com/api/clients

这适用于http:// localhost / api / clients ,但我不知道如何使它适用于非标准端口,如4200。

我也尝试创建一个virtualHost,但它是一样的:

<VirtualHost *:4200>
    ProxyPass /api/clients http://subdomain.domain.com/api/clients
</VirtualHost>

我怎样才能做到这一点 ?

[编辑]:我将RESTAdapter设置为:

var ApplicationAdapter = DS.RESTAdapter.extend({
    namespace: 'api/clients'
});
ember.js ember-cli proxypass
1个回答
4
投票

在开发期间,您应该使用http代理生成器来创建API的路径。 ember help generate列出语法:

http-proxy <local-path> <remote-url>
  Generates a relative proxy to another server.

这将生成仅在开发期间存在的代理(在/server/proxies/ ),并且不在生成构建中编译。 根据您上面提供的内容,这可能是您正在寻找的内容:

ember generate http-proxy api http://subdomain.domain.com

Ember使用node-http-proxy创建代理,因此您可以根据需要使用该文档对其进行更多自定义。

© www.soinside.com 2019 - 2024. All rights reserved.