我用js开发了一个单页应用,数据接口使用appserver的api,遇到如下问题,求解

问题咨询 · tgy3300 · 于 5年前 发布 · 1756 次阅读

我用js开发了一个单页应用,单页应用部署到服务器上后,访问域名为:http://www.a.com

appserver的请求域名为:http://www.b.com

现在 单页应用 使用 appserver 提供的 /customer/login/account 接口进行登录,post请求地址如下:

http://www.a.com/customer/login/account

然后我在nginx里反向代理了

location /customer {
        proxy_pass http://www.b.com;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
    }

运行后提示:this domain is not config in store component

@appserver/config/fecshop_local_services/Store.php文件配置的访问域名是http://www.b.com

提示如上错误是appserver没有识别到我nginx的反向代理

我的这种部署架构有问题没有,还是程序的问题?

共收到 6 条回复 问题提问
Fecmall#15年前 0 个赞

论坛搜索:this domain is not config in store component

发帖前先搜索,是否有帖子。

tgy3300#25年前 0 个赞

我知道 this domain is not config in store component 是哪里出的问题,你没看我懂我的问题

tgy3300#35年前 0 个赞

换个问法,@appserver/config/fecshop_local_services/Store.php文件配置的访问域名是vue的域名还是appserver自己的访问域名呢?有点疑惑!!

我现在@appserver/config/fecshop_local_services/Store.php文件里配置的访问域名是http://www.b.com

vue的访问域名是:http://www.a.com

appserver api 的访问域名是:http://www.b.com

vue调用appserver api接口时,地址是:POST /customer/login/account

完整的接口请求就变成:POST http://www.a.com/customer/login/account

这样肯定访问不到接口数据的,所以我把/customer/login/account从http://www.a.com 代理到 http://www.b.com

location /customer {
        proxy_pass http://www.b.com;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
    }

我这样操作应该可行的吧!!

可结果还是提示

this domain is not config in store component
Fecmall#45年前 0 个赞

1.如果不添加代理,你是否可以正常访问?如果可以,参看2

2.@appserver/config/fecshop_local_services/Store.php 文件里配置的域名,改成:www.a.com , 试试。

3.论坛搜索反向代理,有几个相关的帖子。

tgy3300#55年前 0 个赞

把appserver api 的访问域名改成:http://www.a.com

改成这样vue的访问域名是可以的,

如果我的vue是用electron打包成了桌面软件,那么页面的访问url就是file协议的,没有域名了,那@appserver/config/fecshop_local_services/Store.php文件就配置不了域名了,这种情况怎么办呢

还有如果我有两个js应用调用appserver api接口,哪@appserver/config/fecshop_local_services/Store.php文件能同时配置多个域名吗?

Fecmall#65年前 0 个赞

@tgy3300 #5楼

桌面软件加载数据也可以使用http吧?

@appserver/config/fecshop_local_services/Store.php 可以通过store的方式配置多个访问域名

我建议你先了解一下fecshop的代码结构以及文档吧,多问无益。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics